# Hash Function in Cryptography

This article is all about the Hash Function. Hash Function is a very important topic of cryptography. In this article, we will first have a brief introduction regarding the Hash Functions and then will look into its properties, its way of functioning and the ways by which it is implemented in various encryption techniques.
Submitted by Monika Sharma, on February 07, 2020

### What is a Hash Function?

A Hash Function is a mathematical function that converts a numerical value into another compressed numeric value. So, it compresses the text. Also, it should be noted that the input value for the hash functions can be of arbitrary length, but the output text that it will produce will always be of fixed length.

Representation of the hash function:

The hash functions are usually represented through capital H symbol,

```    H (M) = C
```

Here,

• H() denotes the hash function.
• M denotes the input value (in numeric form)
• And, C denotes the compressed output value, also in numeric form.

### Properties of Hash Functions

1. Compressed output
The hash function always produces a compressed value of the input provided to it.
2. Fixed Length Output
No matter what may be the length of the input value to the hash function, the output that it produces is always of fixed length.
3. Pre-Image Resistance
It is computationally hard to reverse a Hash function. This is due to its compressive nature.
H (X) = Z
Suppose we are provided the Z value, then it is almost impossible to predict the input value X. This protects the system and data from hackers and attackers who have a hash value and are trying to find the input.
4. Second pre-Image Resistance
As the hash functions are compression function with a fixed-length output, it is very hard (almost practically impossible) to have the same hash values for two values. This means that our function also provides us the security from the brute force attacks, because: H (x) ≠ H (y).
5. Collision Resistance
As it is extremely hard to find the second pre-Image of the hash function, this implies that it is rare (almost impossible) for the Hash function to have a collision. Therefore, the hash function is almost collision-free.

### Applications and uses of the hash functions

1. Encryption techniques: Due to the irreversible nature and collision-free properties, the hash function finds its wide use in the advanced encryption techniques used nowadays for ensuring data security and privacy.
2. Used for authentications and integrity checks.
3. To minimize the storage space: As the Hash function is compressive, it takes less amount of space to store the hash value than the original space. This provides us with an efficient way to store our data.

### Drawbacks of the Hash Functions

1. Data retrieval almost impossible:
If you want to store the data in compressed form to minimize space allocation, you can do it with Hash functions but you cannot retrieve back the data in its original form. Therefore, it is better to compress those values using hash functions which will later not be required in its original form and will be required only to check the integrity and correctness.
2. Complexity:
The Hash functions are very complex to understand and implement.