Requirements for any Hash Algorithms!

This blog aims to explain all the requirements for any Hash Algorithm in detail that exists in the present or that can be created in the future!

Harshit Dawar
4 min readMay 18, 2023
Image by Author!

Security is one of the most important topics that exist in this world, if some application is not secure, then irrespective of the features that the application is offering, that application will not be accepted by the end-user.

When we talk about security, Cryptography is the topmost important topic that needs to be understood. Cryptography in itself is a very big topic, & the complete topic in detail can’t be discussed in one blog, a series of blogs is required to cover it. However, for a high-level overview, cryptography is a field that is concerned with secure data transfer between 2 or more clients/parties. There exist a lot of different methods & techniques in cryptography, which I will be discussing one by one in future blogs, that in turn generates a series on cryptography.

Hashing is part of cryptography, it generates a non-human understandable unique value of any given data which helps in keeping the communication process secure.

For Example: If I need to generate the SHA256 (An Hashing method) hash of my name i.e, “Harshit Dawar”, it will be “b30c110bd4bc7757bc8ebecc5da76d3b4d33bbcc4f561619c70b3c514a3a181c”

The above-generated hash is completely non-understandable by any human.

Now, let’s start with the requirements for any Hash Algorithm, there exist 5 requirements for the same.

One-Way

Based on any input, whatever process we are applying to that, we are getting some output, but the point of concern is whether we are able to get back the input from that output or not. If yes, then it is not what we desire.

Any hash algorithm, if it is really good, then it should be able to generate the output from the input, but the input should be non-generable from the output.

For Example, in the example given above, the hash that is generated from the text i.e., “Harshit Dawar” is “b30c110bd4bc7757bc8ebecc5da76d3b4d33bbcc4f561619c70b3c514a3a181c”, but the text should not be generatable from this hash in any scenario.

Deterministic

Any Hashing algorithm, when it is generating some hash, then this algorithm should generate the same hash for the same input text.

For Example, irrespective of the number of times, I am using the same algorithm to generate the hash for the text i.e, “Harshit Dawar”, the hash should always be the same i.e., “b30c110bd4bc7757bc8ebecc5da76d3b4d33bbcc4f561619c70b3c514a3a181c”

Fast Computation

For any hashing algorithm, it is very important that it should support fast computation, since there are many scenarios in which we need the hashing algorithms to run in real-time, therefore, its computation speed should be very fast. Now in case the hashing algorithm is slow, then it will consume a lot of time which will violate the real-time concept, hence, there is no benefit of that hashing algorithm.

Avalanche Effect

This effect states that if there is even a very small change in the input, there should be a drastic change in the output.

For Example:

Text to Hash: "Harshit Dawar"
SHA256 Hash: "b30c110bd4bc7757bc8ebecc5da76d3b4d33bbcc4f561619c70b3c514a3a181c"

Text to Hash: "Harshit Dawar1"
SHA256 Hash: "e757395e85b9d8d7fd8e3c2dadc32a06f5625bb452b983348b80221afbdaab82"

It can be clearly seen from the above example that the 2 output hashes are very much different, however, the change in the input is very small.

It must withstand Collisions

Since the number of inputs has infinite possibilities i.e., there can be an infinite number of distinct inputs, but we cannot have an infinite number of outputs.

For Example, if we consider the SHA256 algorithm, it produces the output with 64 characters, now even if create the combinations for these 64 characters, we still have much more possibilities of inputs, that is why there are chances that for some 2 different inputs, we have the same output i.e, hash, which is a collision.

Therefore, for a good hashing algorithm, it should be able to manage the collision, that is by any means it should be able to generate the hash in such a way that collision doesn’t occur.

I hope my article explains each and everything related to the topic with all the detailed concepts and explanations. Thank you so much for investing your time in reading my blog & boosting your knowledge. If you like my work, then I request you to applaud this blog & follow me on Medium, GitHub, & LinkedIn for more amazing content on multiple technologies and their integration!

Also, subscribe to me on Medium to get updates on all my blogs!

--

--

Harshit Dawar

AIOPS Engineer, have a demonstrated history of delivering large and complex projects. 14x Globally Certified. Rare & authentic content publisher.