MD5 algorithm is basically used for finding the message digest. Basically what happens in MD5 algorithm is that every message is padded into blocks of 512bits each. There are basically 4 rounds of 16 operations each, which implies that in total we perform 64 operations in each block and the output of every block, is fed into the subsequent block. And again the process continues till the last block. The output of the last block is our message digest.

  1. Use of MD5 Algorithm
  2. Working of the MD5 algorithm
  3. Output message digest
  4. Advantages of MD5 Algorithm
  5. Disadvantages of MD5 Algorithm

1) Use of MD5 Algorithm

  • It is used for the purpose of data verification in transmission protocols
  • In many web applications, MD5 hash is used to prevent security breaches, hacking etc. by the way of enhancing security
  • MD5 algorithm was developed mainly for the purpose of security as it takes any message and gives 128bit hash value as output.

2) Working of the MD5 algorithm

There are 5 prominent steps in the working of the MD5 Algorithm. They are,

  • Append padding bits

Initially, when we get the message, it can be of any size say 5000bits, 12345bits, etc. For this message, we add some more bits, which are known as padding bits. And the thing to keep in mind is that bits are added in such a way that, the resultant total number of bits must be 64 bits short from becoming the multiple of 512. And when it comes to padding, we add 1 at the beginning and the rest 0’s.

  • Append length bits

In this step instead of padding bits, we add the length bits. Initially, in first step, we appended the message in such a way that the total number of bits in the message was 64bits short from becoming the multiple of 512. Now we add the length bits in such a way that the total number of bits in the message is perfectly the multiple of 512. That means 64bits; length bits to be precise are added to the message.

  • Initialize MD buffer

In this step, we use 4 buffers of 32 bits each. Let’s name this buffer as A, B, C and D respectively. The use of these buffers will be known in the coming steps. The buffers are to be initialised in this step. The way in which we initialize is given below

A = 0, 1, 2, 3, 4, 5, 6, 7 

B = 8, 9, a, b, c, d, e, f

C = f, e, d, c, b, a, 9, 8

D = 7, 6, 5, 4, 3, 2, 1, 0

  • Process each 512 bit block

Previously it was said that there will be 64 processes, divided into 4 rounds of 16 processes. We use 4 different functions for 4 different rounds. The functions used here F, G, H and I respectively.

In the previous step, we had initialised the buffers namely A, B, C, and D. After the round operation, the output will also be A1, B1, C1, and D1.

The output of B will be fed into C1, C into D1, and D into A1. A will also be fed into Bbut after some process.

First, the output of B, C, and D are taken and the F function is applied to them. We will do the addition modulo by 232 bits for the output of this with A. For this, we add the 32 bits message and again we do the addition modulo by 232 bits. Then we add a 32 bit constant to the output and once again addition modulo by 32bits. At last, we do left shift by s (s can be any value) and addition modulo by 232.

The result of this will be fed to b1. Thus we got the output for all 4 buffers. This is one operation by using F function. There will be a total of 16 operations by using F function, and then 16 operations by using G, H and I functions to make it 64 in all.

The output we get here will be the starting block of the next 512 bit block.

3) Output message digest

This process goes on till the last block of 512 bit is processed. The output of the last 512 bit block is ultimately our message digest. The outputs we get are the blocks of 32 bit. So that makes 4 blocks of 32 bits, which ultimately means 128 bit output. So here we feed 512 bit and get 128 bit as our output.

4) Advantages of MD5 Algorithm

  • MD5 algorithm is very much helpful as it is a bit easier for storing and comparing smaller hashes than the large text of variable length.
  • They are used to store passwords in 128-bit form in UNIX.
  • And it’s easy to develop a message digest from the original message.

5) Disadvantages of MD5 Algorithm 

  • One condition for MD5 Algorithm is that it should not be possible to create the same hash function for 2 different inputs. But this was possible which adds to its disadvantage.
  • MD5 is also known to be slow when compared to other algorithms such as SHA-I


Though there are disadvantages in using MD5 algorithm, we should also focus on the merits by the use of this algorithm. This is indeed faster and easier to use. And many developments are on its way.

So, have you made up your mind to make a career in Cyber Security? Visit our Master Certificate in Cyber Security (Red Team) for further help. It is the first program in offensive technologies in India and allows learners to practice in a real-time simulated ecosystem, that will give them an edge in this competitive world.



Are you ready to build your own career?