Cryptology – MD5 (Message
Digest Algorithm 5)
G Rutvik Sharma 01JST21CB012
Leeladhar Suthar 01JST21CB020
Kushal Madappa 01JST21CB021
Introduction
•MD5 developed by Ronald Rivest in 1991
•Produces 128-bit hash value from any input
•One-way function: original input cannot be retrieved
•Initially used in:
▪ Digital signatures
▪ Password hashing
▪ SSL certificates
•Now cryptographically broken
•Still used for non-secure applications
Working of MD5
Step 1: Input Conversion
•Input message is converted to a binary format using ASCII encoding.
Step 2: Padding
•The binary message is padded by adding a '1' bit, followed by '0' bits.
•Padding continues until the message length is 448 mod 512 bits.
•This ensures total length = 64 bits short of a 512-bit block.
Step 3: Appending Message Length
•A 64-bit binary representation of the original message length (before padding) is appended to the
end.
•The total message length is now a multiple of 512 bits.
Cont.
Step 6: Four Rounds of Transformation
Step 4: Initialize Buffers
•Each block is processed through 4 rounds, each having 16
•Four 32-bit buffers (registers) are
operations.
initialized with fixed values: •Uses 4 nonlinear logical functions:
•A = 0x67452301, B = 0xefcdab89, •F, G, H, I (each combining A, B, C, D in different ways).
C = 0x98badcfe, D = 0x10325476 •A unique constant value and left-rotation are used in each
operation.
Step 5: Divide into 512-bit
Blocks Step 7: Final Output
•After all blocks are processed, the updated values of A, B, C, and
•The message is split into 512-bit
D are concatenated.
chunks for processing.
•The result is a 128-bit final hash, usually displayed as a 32-
character hexadecimal string.
Python Implementation
• Uses hashlib library in Python
• .encode() converts string to bytes
• md5() generates hash
• .hexdigest() returns 32-character
hash
Example – Using ‘hello’ as plaintext
Step 1: Convert the input to binary
Cont.
• Step 2: Padding and appending :
• MD5 processes 512-bit blocks. “hello" (40 bits) needs padding.
• Append '1' bit → 1
• Add '0' bits to make 448 bits (leaving space for length encoding).
• Append 64-bit representation of the original message length (40 bits).
• Final padded message: 01101000 01100101 01101100 01101100 01101111 1
000000...000000 (512 bits total).
Cont.
Step 4: Performing 4
Step 3: Initializing 4
rounds of operations
MD Buffer variables
for 16 steps each
Cont.
• Step 5: Final 128-bit hash obtained in hexadecimal:
MD5 Hash of “hello":5d41402abc4b2a76b9719d911017c592
Advantages
• Fast and efficient computation
• Produces fixed-length output (128 bits)
• Easy to implement, widely supported
• Useful for:
• Checksums
• File fingerprinting
• Data validation
• Doesn’t require encryption key
Disadvantages
• Not collision resistant (same hash for different inputs)
• Vulnerable to:
• Collision attacks
• Preimage and second preimage attacks
• Can be cracked using modern hardware
• No key mechanisms
• Not suitable for secure applications
MD5 vs Previous Versions (MD2 & MD4)
MD2 (1989) MD5 (1991)
• Designed for 8-bit systems • Improved version of MD4
• Slow and outdated • Uses 4 rounds of 16 operations (vs. 3 in
• Weak against modern attacks MD4)
MD4 (1990) • More complex padding & transformation
• Faster, for 32-bit systems • Better initial resistance to attacks
• Poor security — easily broken
• Became a widely-used standard for
• Vulnerable to collision and preimage integrity checks
attacks
MD5 offered better security, efficiency, and platform compatibility than its predecessors —
though it is now outdated for secure cryptographic use.
MD5 vs modern hash algorithms like SHA-1,
SHA-256 etc.
Applications
• Data integrity verification (file checksums)
• Digital signatures (legacy systems)
• Duplicate file detection (fingerprinting)
• Malware detection (using MD5 hash)
• CAPTCHA hashing and database validation
Conclusion
• MD5 was a key algorithm in early cryptography
• Now outdated due to security weaknesses
• Replaced by secure alternatives:
• SHA-256
• Bcrypt
• Argon2
• Still useful in non-critical applications like checksums