Why MD5 Is Dead: A Security Architect's Warning About Hash Algorithms
MD5 was broken in 2004. Yet I still see it used for password hashing in 2024. Here's why MD5 is dangerous, what to use instead, and how to audit your codebase.
Let me show you an attack.
import hashlib
# MD5 collision — two different inputs, same hash
input1 = b"d131dd02c5e6eec4693d9f06..."
input2 = b"d131dd02c5e6eec4693d9f06..." # DIFFERENT data
hash1 = hashlib.md5(input1).hexdigest()
hash2 = hashlib.md5(input2).hexdigest()
print(hash1 == hash2) # True. Same hash. Different data.
This is a collision attack. Two completely different files produce the same MD5 hash. An attacker can swap a legitimate file with a malicious one, and your MD5 checksum won't catch it.
The Timeline of MD5's Death
- 1991: MD5 published by Ron Rivest
- 1996: First collision attacks on MD5's compression function
- 2004: Full collision demonstrated — MD5 is broken
- 2008: Attackers forge SSL certificates using MD5 collisions
- 2012: Flame malware uses MD5 collision to fake Microsoft signature
- 2024: People still use MD5 for passwords. Sigh.
Why MD5 Is Dangerous
1. Collision Attacks Are Trivial
You can generate an MD5 collision in seconds on a modern laptop. Tools like hashcat can produce collisions at billions of attempts per second.
2. Length Extension Attacks
MD5 is vulnerable to length extension — if you know MD5(secret + data), you can compute MD5(secret + data + more_data) without knowing the secret. This breaks naive MAC constructions.
3. Rainbow Tables
Pre-computed MD5 tables cover every 8-character alphanumeric password. An attacker looks up your hash and gets your password in milliseconds.
What to Use Instead
| Algorithm | Security | Speed | Use Case |
|---|---|---|---|
| MD5 | ❌ Broken | Fast | Checksums only (non-security) |
| SHA-1 | ❌ Broken | Fast | Git commits (non-security) |
| SHA-256 | ✅ Secure | Medium | File integrity, digital signatures |
| SHA-512 | ✅ Secure | Medium | High-security applications |
| bcrypt | ✅ Secure | Slow | Password hashing |
| Argon2 | ✅ Secure | Slow | Password hashing (modern) |
Use a Hash Generator to generate SHA-256 hashes for file integrity verification.
The Password Hashing Problem
If you're storing passwords with MD5 or SHA-256 alone, you're doing it wrong. Passwords need slow hashing — specifically designed to resist GPU attacks.
// WRONG: Fast hash, vulnerable to brute force
const hash = crypto.createHash('md5').update(password).digest('hex');
// RIGHT: bcrypt with salt and work factor
const bcrypt = require('bcrypt');
const hash = await bcrypt.hash(password, 12); // 12 rounds = ~250ms per hash
The difference: an attacker can test 10 billion MD5 hashes per second, but only ~1,000 bcrypt hashes per second. That's a 10-million-fold difference in attack resistance.
Audit Your Codebase Today
Search for these patterns:
grep -r "md5\|MD5\|createHash('md5')" --include="*.js" --include="*.py" --include="*.java"
grep -r "SHA1\|sha1\|createHash('sha1')" --include="*.js" --include="*.py"
Every match is a potential vulnerability. Replace MD5 with SHA-256 for integrity checks, and bcrypt/Argon2 for passwords.
Generate SHA-256 hashes instantly with our free Hash Generator — supports SHA-256, SHA-512, and more. All processing happens in your browser.
Try It Yourself
Put what you've learned into practice with our free online tools.
Related Articles
Man-in-the-Middle Attacks: A Practical Demonstration
I intercepted my own traffic on a public WiFi. Here's everything I saw...
HTTP Headers for Security Hardening: The Complete Set
These 12 HTTP headers transform your site from vulnerable to hardened. No exceptions...
CSRF Attacks and Defense: A Complete Guide
CSRF is the attack everyone forgets about. Until it hits them. Here's how to prevent it...