MD5 vs SHA-256: Why MD5 Is Broken for Passwords but Fine for Checksums
MD5 is famously broken for security, yet package managers and cloud buckets still use it for file checksums. Here is how collisions work and what to use today.
Every developer hears early on that MD5 is broken. Security scanners flag it, auditors reject it, and modern cryptographic libraries discourage its use.
Yet if you check Amazon S3 or Cloudflare R2, every object still lists an ETag calculated with MD5. Package managers still publish MD5 checksums alongside downloads.
The quick answer is: MD5 is vulnerable to collision attacks, making it dangerous for passwords, digital signatures, and certificates. For non-adversarial file integrity (detecting accidental disk corruption or network drops), MD5 remains fast, lightweight, and completely fine.
You can generate MD5, SHA-1, SHA-256, and SHA-512 hashes client-side in your browser with our hash generator.
Here is why MD5 broke for security, and how to pick the right hashing algorithm for your stack.
What makes a cryptographic hash secure?
A cryptographic hash function must guarantee three properties:
- Pre-image resistance (One-way): Given a hash
H, it must be computationally impossible to find the original messageM. - Second pre-image resistance: Given a message
M1, you cannot find a different messageM2that produces the exact same hash. - Collision resistance: You cannot find any two different inputs that produce the same hash output.
A secure hash function acts like a digital fingerprint. If a single bit in a 10 GB file changes, the entire hash output changes unpredictably.
How MD5 broke: The collision attack
In 2004, cryptographers discovered practical collision attacks against MD5. Today, generating two different files with the identical MD5 hash takes a few seconds on a consumer laptop.
This is fatal for security: - Malicious certificates: Researchers generated a fraudulent SSL certificate authority certificate with the same MD5 hash as a legitimate certificate, completely breaking HTTPS validation. - Backdoored software: An attacker can compile a clean executable, create a trojanized version that shares the identical MD5 hash, and swap them out without tripping verification tools.
For any security boundary, digital signature, or authentication flow, MD5 is completely disqualified. Use SHA-256 or SHA-512 instead.
MD5 Output (128 bits): d41d8cd98f00b204e9800998ecf8427e
SHA-256 Output (256 bits): e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Why MD5 is still used for file checksums
If MD5 is broken, why do cloud providers and deployment scripts still use it?
Because disk drives and network cables do not launch collision attacks.
When you download an ISO image or upload a video to object storage, your enemy is not a nation-state attacker trying to craft a duplicate payload. Your enemy is a dropped packet, a bad cable, or cosmic ray bit-rot on a storage drive.
In non-adversarial scenarios, MD5 has distinct advantages: - Speed: MD5 computes roughly twice as fast as SHA-256 on CPU architectures without hardware crypto acceleration. - Short output: At 32 hexadecimal characters (128 bits), it takes half the storage of SHA-256 in database columns and HTTP headers.
If an accidental corruption flips a bit during transmission, MD5 detects it 100% of the time.
Never use plain hashes for passwords
Whether you choose MD5 or SHA-256, neither one should ever be used to hash passwords.
Both MD5 and SHA-256 were designed to be as fast as possible. A modern graphics card can test over 100 billion SHA-256 guesses per second. If an attacker dumps your database, fast hashes can be brute-forced in minutes.
For password storage, always use slow, memory-hard algorithms like Argon2id, bcrypt, or scrypt. These algorithms force hardware to wait milliseconds per guess, rendering brute-force attacks impossible.
| Algorithm | Digest Size | Collision Secure? | Best Use Case |
|---|---|---|---|
| MD5 | 128 bits | No (Broken) | Non-security file integrity & ETags |
| SHA-1 | 160 bits | No (Broken) | Legacy Git commit references |
| SHA-256 | 256 bits | Yes | Digital signatures, API tokens, blockchain |
| bcrypt / Argon2 | Variable | Yes (Slow) | Password hashing only |
To calculate hashes for API verification or compare digests across files, test your strings in the ToolQuilt hash generator.