RFC 1321 MD5 Hash Digest Mathematical Formulation
The MD5 algorithm processes arbitrary inputs in 512-bit blocks through 64 non-linear compression operations across four 32-bit state registers ($A, B, C, D$).
1. Four Non-Linear Bitwise Boolean Functions
F(X,Y,Z) = (X ∧ Y) ∨ (¬X ∧ Z)
G(X,Y,Z) = (X ∧ Z) ∨ (Y ∧ ¬Z)
2. Register Compression State Update Step
A ← B + ((A + f(B,C,D) + M_k + T_i) ⋘ s)
Step-by-Step Hash Generation Breakdown (Example: "hello")
Step 1: Byte Padding to Modulo 512 Bits
Input length = 5 bytes (40 bits). Append '1' bit (0x80) + 424 zero bits + 64-bit length representation.
Step 2: Initialize State Registers (A, B, C, D)
A = 0x67452301, B = 0xEFCDAB89, C = 0x98BADCFE, D = 0x10325476
Step 3: Final 32-Character Hexadecimal Digest
MD5("hello")=5d41402abc4b2a76b9719d911017c592
Cryptographic Hash Algorithms Comparison
| Algorithm | Output Bits | Hex Chars | Security Status | Recommended Use |
|---|---|---|---|---|
| MD5 | 128 bits | 32 chars | Legacy / Insecure | ETags, cache keys, checksums |
| SHA-1 | 160 bits | 40 chars | Deprecated | Git commit IDs (legacy mode) |
| SHA-256 | 256 bits | 64 chars | Cryptographically Secure | TLS certificates, Bitcoin, JWT signing |
| BLAKE3 | 256 bits | 64 chars | Ultra-High Speed Secure | Modern tree hashing & deduplication |