← All guides

MD5 vs SHA-256: Which Hash Should You Use?

A hash turns any input into a fixed-length fingerprint. Learn how hashing works, why MD5 and SHA-1 are broken, and when to use SHA-256 instead.

A hash function turns any input into a fixed-length fingerprint — the same input always gives the same output, but you cannot reverse the output back to the input. It is the basis of checksums, deduplication and digital signatures.

What makes a hash useful

  • Deterministic — identical input always yields identical output
  • Fixed length — a 3-byte file and a 3-GB file both produce, say, a 64-character SHA-256 digest
  • One-way — you cannot recover the original data from the hash
  • Avalanche effect — changing one bit changes the whole output

MD5 and SHA-1 are broken

MD5 (128-bit) and SHA-1 are fast but cryptographically broken: attackers can craft two different inputs with the same hash (a collision). They are fine for non-security checksums, but must not be used for signatures, certificates or integrity where an attacker is involved.

Use SHA-256 for security

SHA-256 (part of the SHA-2 family) has no practical collision attacks and is the current default for integrity and signatures. When you need to prove data has not changed, choose it over MD5.

Passwords need more than a hash

Never store passwords with a plain fast hash. Use a slow, salted algorithm like bcrypt or Argon2 designed to resist brute force. For message authentication, combine a key with a hash — see HMAC.

Try it

Hash any text with MD5, SHA-1 and SHA-256 side by side in the hash generator, entirely in your browser. Related: What is Base64 encoding.