SHA-256 vs MD5: Which Hash Algorithm Should You Use?
A practical guide to picking a checksum for download verification, deduplication, and integrity.
A cryptographic hash function turns any input — a file, a message, a string — into a fixed-length fingerprint. Identical inputs always produce identical fingerprints, and even a one-byte change produces a wildly different output. We rely on that property whenever we verify downloads, detect duplicates, or compare backups.
The browser supports MD5, SHA-1, SHA-256, SHA-384, and SHA-512 through the Web Crypto API. They are not interchangeable; the right choice depends on the threat you care about.
The short answer
- SHA-256 — the right default for almost everything: download verification, deduplication, integrity checks, content-addressed storage.
- SHA-512 — same security as SHA-256, slightly faster on 64-bit CPUs, longer output. Use it only if a publisher provides one.
- SHA-1 — broken for security since 2017. Still acceptable as a checksum against accidental corruption, but not against deliberate tampering.
- MD5 — broken since 2004. Useful only for non-security tasks (deduplication, cache keys) where collisions are not adversarial.
Why MD5 and SHA-1 are "broken"
Researchers have demonstrated that an attacker can deliberately craft two different files with the same MD5 (and now SHA-1) hash. This is called a collision attack. If a publisher posts an MD5 hash for a download, an attacker who can substitute the file can also substitute it with a malicious twin that hashes the same. SHA-256 has no such known attack, and the cost of finding one is currently astronomical.
Collisions don't matter for non-adversarial uses. If you are deduplicating photos on your own disk, MD5 is fine — there is no attacker. If you are verifying a download from the internet, use SHA-256.
What about speed?
On modern hardware all five algorithms are fast enough that you won't notice the difference for typical files. SHA-256 is hardware-accelerated on most recent CPUs (Intel SHA extensions, ARMv8 crypto extensions). For multi-gigabyte files, expect 100–500 MB/s in the browser; the bottleneck is usually disk I/O, not the hash.
How to verify a download in practice
- Find the publisher's
.sha256or "checksums" file alongside the download. - Drop the downloaded file into the Hash Comparator.
- Paste the published hash into the Expected Hash field.
- Pick the algorithm the publisher used (usually SHA-256).
- A green Match means the file is intact; a red No Match means redownload.
Want to see all five hashes for a file at once? Use the File Hash Checker.