How does the MD5 hashing algorithm work?

19 views
0

How does the MD5 hashing algorithm work?

In: 4

Uuh, are you asking how hashing algorithms in general work, or how specifically the md5 one works? If it’s the latter, I’m not sure it’s possible to break it down to ELI5…

1. Start with a message
2. Next you break M up into 512 bit long chunks. If the last chunk is not 512 bits long you pad it out to be 512 using a known algorithm.
3. Create four 32 but values called A, B, C, and D and set them to predetermined start values.
4. For each 512 bit chunk do the following
1. Break the 512 bit chunk into sixteen (16) 32 bit pieces and store then in an array called M
2. For value i from 0 to 63 (aka 64 times), using the current values of A, B, C, and D, along with i and the values in the M array perform a predetermined set of operations to calculate new values of A, B, C, and D.
3. Proceed to the next 512 bit chunk and repeated sub steps 1 and 2.
5. Once all the 512 bit chunks have been processed, convert A, B, C, and D into the hexadecimal representation of their value and store then as strings.
6. Create a new string by appending the strings of A, B, C, and D together. This will give you a new 32 character string (aka 128 bit value).
7. Enjoy your MD5 hash. Do not use it for cryptography, the algorithm is not crypto safe.