MD5 vs SHA-1 vs SHA-256: Which Hash Function Should You Use?
Published June 23, 2026
Prepared by Innealan Editorial
Hash functions take an input of any size and produce a fixed-size “digest.” The useful first question is not “which one is strongest?” but “am I detecting accidental corruption, protecting against a malicious change, or storing a password?” The answer changes the choice.
MD5: broken, checksum use only
MD5 produces a 128-bit digest. It was widely used in the 1990s–2000s but is now cryptographically broken: practical collision attacks (two different inputs producing the same hash) have been demonstrated since 2004. Do not use MD5 for passwords, digital signatures, or anything security-sensitive. It’s still fine for non-adversarial checksums, like verifying a file wasn’t accidentally corrupted during a download.
SHA-1: deprecated
SHA-1 produces a 160-bit digest and was the successor to MD5. In 2017, Google and CWI Amsterdam demonstrated a practical collision (the “SHAttered” attack). Major browsers and certificate authorities have deprecated SHA-1 for TLS certificates and code signing. Avoid it for anything new.
SHA-256 / SHA-512: current standard
Part of the SHA-2 family, these remain secure with no known practical attacks. SHA-256 (256-bit digest) is the most widely used today. It’s what Bitcoin uses for proof-of-work, and what Git is moving toward as an alternative to SHA-1 for commit hashing. SHA-512 uses 64-bit internal operations and can be faster on 64-bit hardware.
Important: none of these are for passwords
Even SHA-256 should not be used directly to hash passwords, because it’s fast. An attacker with a stolen password database can try billions of guesses per second on commodity GPUs. Password storage should use a purpose-built, deliberately slow algorithm like bcrypt, scrypt, or Argon2, which include built-in salting and configurable work factors.
For example, comparing a downloaded file’s published SHA-256 digest can reveal accidental corruption. It cannot establish that a download page was trustworthy in the first place. The security claim depends on how the digest was obtained.
Quick reference
| Algorithm | Digest size | Status | Good for |
|---|---|---|---|
| MD5 | 128-bit | Broken | Non-security checksums only |
| SHA-1 | 160-bit | Deprecated | Legacy compatibility only |
| SHA-256 | 256-bit | Secure | File integrity, general hashing |
| SHA-512 | 512-bit | Secure | File integrity, general hashing |
| bcrypt/Argon2 | N/A | Secure | Password storage specifically |
Try all four (MD5, SHA-1, SHA-256, SHA-512) side by side with our Hash Generator, computed locally using the Web Crypto API.