DEV Community

Chinwe Okonkwo
Chinwe Okonkwo

Posted on

Cryptographic Hash Function

Cryptographic Hash Function also known as (Hash Function or Hash) are strings of characters of any length that are converted when inputted into an encrypted output of a fixed length size that is in most cases irreversible.

Cryptographic hash functions are essential when building a decentralized trust protocol because when inputting the string (dark wallet puzzle) in a cryptographic function it will always produce the same hash result. Any small changes on the target string for a hash function lead to outsized effects. Change one letter in the string you hashed in above, it may be as simple as capitalizing the "d" but it will go a long way toward changing the way the hash looks completely.

Image description
Interactive Code: Cryptographic Hash Function Sandbox A, simple nice way to see the characteristics of hash functions.

The Three Main Properties Hash Function

Uniqueness You can be rest assured that if you put in the string dark wallet puzzle in a cryptographic function, it will always produce the same hash outcome. This avoids the “hash collision” problem, in that we don’t have to worry about two strings getting the same hash result.

Avalanche Effect No matter how small you change the value you passed to the hash function, it leads to huge effects. Change one letter in the string you hashed just like in the image above where I capitalised the "d" in Dark wallet puzzle. You'll see it did not change a little bit but a lot. This illustrates the second characteristic of a good hashing function — “The Avalanche Effect”. This says a single change in the string passed will cause a successive series of changes.

Speed The Cryptographic hash functions can also run incredibly fast with little overhead and still maintain their security. This is more of a logistical concern. The hashing function can’t be too slow, otherwise it causes delays. But it also can’t be too fast or it will be easier to find collisions. It needs to be fast for processing but slow for hacking.

Reference | Resources

Article: How Hash Algorithms Work
Article: Cryptographic Hash Function (Wikipedia)

Top comments (0)