# What is MD5 (Message Digest algorithm 5)?

Hello guys, welcome back. In this module, I will be discussing what is MD5 (Message Digest algorithm 5). After reading this module, you will get to know about message digest, advantages, and disadvantages. Now, let’s begin to know about it. ## What is MD5 (Message Digest algorithm 5)?

MD5 or Message digest algorithm is a hash function that is used in cryptography. It is the 5th version of the Message-Digest algorithm which is faster than any other version of message digest (MD) like MD4. It was developed by Ron Rivest in 1991 to produce a 128-bit or 16 bytes message digest. This algorithm or function takes an input message of arbitrary length to produce a 128-bits hash value or message digest.

A big file must first be safely ‘compressed,’ before being encrypted with a secret key, and MD5 was developed for this purpose. Message Digest 5 is a little more difficult to understand than Message Digest 4.

When it comes to cryptographic authentication, IETF says that MD5 hashes are no longer considered secure.

## How does MD5 work?

A 512-bit string is divided into 16 words of 32 bits each using the MD5 message-digest hashing method. MD5 generates a 128-bit message digest as a result of the operation.
There are four steps involved in producing a message digest:

1. Appending padding bits to the original message.
2. Appending length bits.
3. Initializing MD or Message digest buffer.
4. Processing of messages in 16-word blocks to produce the final output or result.

Let’s go through the steps one by one now.

### Appending padding bits to the original message

Padding is the process of adding more bits to the original message. Additions of padding bits must be made in such a way that the resulting total number of bits falls 64 bits short of the multiple of 512. The initial bit of padding is a 1, while the remaining bits are all zeros.

### Appending of length bits

In this step, we add length bits to the above message generated i.e., the original message and padding bits. We combine the length bits in such a way that the message’s overall bit length is a perfect multiple of 512. Thus, 64-bits are added to the message.

### Initializing MD or Message digest buffer

In this phase, four 32-bit buffers are used. Let’s say there are four buffers, E, F, G, and H. Each of these buffers has a size of 32 bits, and they are set up as follows:

Word E = 01 23 45 67
Word F = 89 ab cd ef
Word G = fe dc ba 98
Word H = 76 54 32 10

### Processing of each block

Each 512-bit block is split into 16 smaller blocks, each of 32 bits. There are four rounds of processing.

To begin, we use four auxiliary functions, each of which accepts three 32-bit words as input and outputs one 32-bit word as a result. These functions make use of logical operators such as AND, XOR, OR, and NOT.

 P(p, q, r) p and q or not (p) and r Q(p, q, r) p and r or q not (r) R(p, q, r) p xor q xor r S(p, q, r) q xor (p or not (r))

This continues until the final 512-bit block has been processed. The final 512-bit block’s output is the message digest.

Now, after seeing the working of MD5. Now, let’s look at some of the advantages and disadvantages of MD5.

## What are the advantages of MD5?

• It’s easier to compare and store smaller hashes using MD5 Algorithms than it is to store a large variable-length text.
• By using MD5, passwords are stored in 128-bit format.
• You may check for file corruption by comparing the hash values before and after transmission. To prevent data corruption, file integrity tests are valid once the hashes match.
• A message digest can easily be created from an original message using MD5.

## What are the disadvantages of MD5?

• When compared to other algorithms like the SHA algorithm, MD5 is comparatively slow.
• It is possible to construct the same hash function for two distinct inputs using MD5.
• MD5 is less secure when compared to the SHA algorithm since MD5 is more vulnerable to collision attacks.

I hope you will find this module to be useful. You may also check out our other tutorials and blogs on our website for more exciting and informative content.