How to use MD5, SHA-1, and SHA-256 without getting fooled
What hashes are for, why MD5 and SHA-1 are still useful (just not for security), and the three cases where SHA-256 is the right answer.
A hash function takes any input and produces a fixed-length output. Same input → same output, always. Different input → almost certainly different output. That deterministic-but-spread-evenly property makes hashes useful for everything from cache keys to file integrity checks to cryptographic signatures.
The Hash Generator gives you five common hashes for any input. This guide is the cheat sheet for which to use.
The five hash functions, in two minutes
- MD5 (1992): 128-bit output, very fast. Cryptographically broken since 2004 — collisions can be found in seconds. Still useful for non-security uses.
- SHA-1 (1995): 160-bit output. Cryptographically broken since 2017 (Google's "SHAttered" attack). Same caveat — still useful for non-security uses.
- SHA-256 (2001): 256-bit output. The modern default. Cryptographically strong.
- SHA-384 / SHA-512 (2001): 384 / 512-bit outputs from the same SHA-2 family. Strong; used when you want extra collision resistance.
The "broken" label is important: MD5 and SHA-1 can be reversed for non-trivial inputs, and an attacker can construct two different inputs that produce the same hash. For anything where collisions are a security problem, use SHA-256 or stronger.
The three legitimate use cases
1. Content-addressing.
You have a file. You want a stable ID that's a function of the file's content. Hash it. Two files with the same content → same ID. Different content → different ID.
For non-adversarial cases (cache keys, dedup, change detection), MD5 or SHA-1 is fine — they're fast and collisions in practice never happen on random data. Git, famously, used SHA-1 for years before migrating to SHA-256.
2. Integrity checks.
You download a 1 GB ISO and the website publishes a SHA-256 of it. You compute the hash of your downloaded file and compare. If they match, the file wasn't corrupted in transit.
For this use case, always use SHA-256 minimum. MD5/SHA-1 here is dangerous: an attacker who controls the download mirror could substitute a malicious file with the same MD5.
3. Password hashing. DO NOT USE THESE.
If you're hashing passwords, you should be using bcrypt, scrypt, argon2, or PBKDF2. Those are designed to be slow, salted, and resistant to GPU-accelerated cracking. Plain SHA-256 of a password is fast — a modern GPU can compute billions of SHA-256 hashes per second.
The Hash Generator does not solve password hashing. Don't try to make it.
Why we still ship MD5
The Hash Generator includes MD5 because it's genuinely useful for:
- Generating cache-busting keys (
?v=query params for static assets). - Quick "did this string change?" checks.
- Compatibility with old systems that emit MD5 hashes (a lot of them).
For these uses, the speed of MD5 is the feature. Just don't extend that comfort to cases where someone might intentionally craft a collision.
How to hash a file (since the tool only hashes text)
You have a file, you want its hash. On the command line:
- macOS:
shasum -a 256 yourfile.zip - Linux:
sha256sum yourfile.zip - Windows PowerShell:
Get-FileHash yourfile.zip -Algorithm SHA256
Match the output against the publisher's checksum. If equal, you have a clean copy.
A file-hashing version of this tool is on the roadmap. For now, text-only is enough for the everyday "hash this string" use case.