Introduction to Hash Functions
Hash Functions
Hash functions are most commonly used mathematical functions in cryptography for implementing security. A Hash function converts an input value of any arbitrary size to fixedsize value. Thus, the input can be of any length but the output generated is always of a fixed length. The output generated is called hash values or hashes.
One more important thing to be noted is Hash Functions and Cryptography are altogether totally different from each other. Encryption is a two way function i.e. encrypted data needs to be decrypted using a private key, thus they are reversible. Hashing or hash functions are one way functions i.e. hashes cannot be reversed. Thus, hashing is faster than cryptography.
Most common use of hashing is password checking. When the user enters the password, the hash of the password is generated and compared with the hash in the database. If both the hashes are the same then the user is allowed to login else the user needs to enter the password again.
Popular Hash Functions
Following are the widely used Hash functions –
1) MD – It stands for Message Digest. It can be MD2, MD4, MD5 and MD6. MD is a 128 bit Hash function.
2) SHA – It stands for Secure Hash Algorithm. It can be SHA0, SHA1, SHA2 and SHA3. SHA224, SHA256, SHA384, and SHA512 are variants of the SHA2 family.
3) RIPEMD – It stands for RACE Integrity Primitives Evaluation Message Digest. RIPEMD, RIPEMD128, and RIPEMD160 are widely used. 256 and 320bit versions of this algorithm also exist.
4) Whirlpool – Whirlpool is 512 bit hash function and a modified version of AES. WHIRLPOOL0, WHIRLPOOLT, and WHIRLPOOL are three versions of Whirlpool.
Properties of Hash Functions
An ideal hash function is desired to possess the following properties to be effective from various attacks from attackers. They are as follows –
 PreImage Resistance

 PreImage Resistance means that the hash function could not be reversed.
 In simple words, if any hash function “a” produces a hash value “c”, then it should be very difficult to find any input value “b” that hashes to “c”.
 This property makes it impossible for an attacker who has a hash value and is trying to find the input.
2) Second PreImage Resistance

 Second PreImage Resistance means for any input and its hash value, it should be very difficult to find a different input generating the same hash.
 In simple words, if any hash function for an input “a” produces a hash value h(a), then it should be hard to find any other input value “b” such that h(b) = h(a).
3) Collision Resistance

 Collision Resistance means it should be very difficult to find two different inputs of any length which produces the same hash. This property is also known as collision free hash function. This property prevents a widely known attack called hash collision attack.
 In simple words, for a given hash function h, it is very difficult to find any two inputs x and y so h(x) = h(y).
 This collision free property confirms that these collisions should be hard to find for a given hash function.
 Also, it is this property that makes it hard for an attacker to find two input values generating the same hash.
Hash Functions Application
Following are the fields where Hash function is widely used –
 Cryptocurrency
 Password Verification for Authentication
 Data and File Integrity Check
 Digital Signature
Sources
 https://www.geeksforgeeks.org/whatarehashfunctionsandhowtochooseagoodhashfunction/
 https://www.tutorialspoint.com/cryptography/cryptography_hash_functions.htm
 https://www.includehelp.com/cryptography/applicationsofhashfunction.aspx
 https://www.investopedia.com/news/cryptographichashfunctions/