Common Hash Functions: MD5 and SHA-1
You'll learn why MD5 and SHA-1, once-standard hash functions, are now considered unsafe for cryptographic use.
The Legacy Giants
MD5 (Message Digest 5) and SHA-1 (Secure Hash Algorithm 1) were the workhorses of cryptographic hashing for decades. MD5 produces a 128-bit (16-byte) hash output, while SHA-1 generates a 160-bit (20-byte) digest. Both were designed to take arbitrary-length input and produce a fixed-size fingerprint that appeared random and unique.
How They Work
Both functions use similar approaches: they break input into blocks, process them through multiple rounds of bitwise operations (shifting, rotating, XOR operations), and mix the data extensively to create avalanche effects—where changing one input bit flips approximately half the output bits.
MD5 uses four rounds of operations with 16 steps each. SHA-1 uses five rounds with 80 total steps, making it theoretically more resistant to attacks than MD5.
Why They're Deprecated
Despite their widespread historical use, both are now broken:
- MD5: Collision attacks became practical in 2004. Researchers could generate two different files with identical MD5 hashes in seconds on modern hardware.
- SHA-1: Google demonstrated a practical collision in 2017, proving it violated collision resistance—one of the fundamental properties you learned earlier.
These weaknesses mean attackers could forge digital signatures, create malicious files that pass integrity checks, or undermine certificate authorities.
Modern Alternatives
The cryptographic community has moved to SHA-2 (SHA-256, SHA-512) and SHA-3 family hashes, which remain secure with significantly larger output sizes and improved designs.
Key Takeaway: MD5 and SHA-1 are deprecated legacy hash functions vulnerable to collision attacks; they should never be used for security-critical applications today, only for non-cryptographic purposes like checksums in trusted environments.