Hashing is intended to verify and guarantee data integrity and authentication. A hash function takes binary data(message), and produces a condensed representation, called a hash. The hash is likewise regularly called a Hash value, Message digest, or Digital fingerprint. Hashing depends on a one way numerical capacity that is generally simple to compute, yet essentially harder to reverse.
Hash function properties
Take an arbitrarily length of clear text data to be hashed.
Put it through a hash function.
It produces a fixed length message digest (hash value).
H(x) is:Relatively easy to computer for any given x.
One way and not reversible.
If a hash function is hard to invert,then it is considered as one-way hash.
Two well-known hash functions are:
- MD5
- SHA-1
MD5
MD5 algorithm is a hashing algorithm that was developed by Ron Rivest. It used in a variety of Internet applications nowadays. It is a one way function that makes it simple to compute a hash from given input data, yet makes it unfeasible to compute input data given just a hash value.
How does the MD5 wors?
Step 1:Append Padding Bits
Padding implies adding additional bits to original message. So in MD5 original message is padded with the end goal that its length in bits is congruent to 448 modulo 512. Padding is done with the end goal that the absolute bits are 64 less being a multiple of 512 bits length.
Padding is done regardless of whether the length of the original message is as of now congruent to 448 modulo 512. In padding bits, the only first bit is 1 and the rest of the bits are 0.
Step 2: Append Length
After the padding, 64 bits are inserted toward the end which is utilized to record the length of the original input. Modulo 2⁶⁴. Now, the subsequent message has a length multiple of 512 bits.
Step 3: Initialize MD buffer
A four-word buffer is used to calculate the values for message digest. Here A, B, C, D are 32- bit registers and they are initialized in following way
Step 4: Processing message in 16-word block
MD5 uses the auxiliary functions that take the input as three 32-bit number and produces a 32-bit output. These functions use logical operators such as OR, XOR, NOR.
The content of four buffers are mixed in with input utilizing this auxiliary buffer and 16 rounds are performed utilizing 16 basic operations.
Output-
After all, rounds have performed the buffer A, B, C, D contains the MD5 output beginning with lower bit A and finishing with higher bit D.
SHA-1
SHA-1 algorithm takes a message of less than 2⁶⁴ bits in length and gives a 160-bit message digest. It is slightly slower than MD5, yet the larger message digest makes it more secure against brute-force collision and inversion attacks.