Skip to the content

Contact usFree tools · No signup · Files stay on your device

Security Tools

MD5 vs SHA-1 vs SHA-256: which hash should you use?

MD5 vs SHA-1 vs SHA-256: which hash should you use?

If you only need one answer, it is this: use SHA-256. It is built into every browser, programming language and operating system, and nobody has found a practical way to attack it. MD5 and SHA-1 are older, shorter and broken for security, though you will still meet them everywhere, so it helps to know what they are good for. You can compare all three on your own text or file in the free Hash Generator, which shows them side by side.

This post explains the real difference, where each one is still acceptable and which to choose for common jobs.

The three hashes at a glance

A hash function turns any input into a fixed-length fingerprint. The same input always gives the same result. A change of one letter gives a completely different one. You cannot work backwards from the fingerprint to the input.

Here are the three results for the text hello, as the Hash Generator prints them:

Algorithm Hash of hello Length
MD5 5d41402abc4b2a76b9719d911017c592 32 hex digits (128 bits)
SHA-1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 40 hex digits (160 bits)
SHA-256 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 64 hex digits (256 bits)

The length alone often tells you which algorithm a checksum uses, and the Hash Generator uses it too: if you paste a hash that does not match, its note says which algorithm that many digits fits.

Why MD5 and SHA-1 are called broken

A hash is meant to be collision resistant: nobody should be able to produce two different inputs with the same hash. That promise is what makes a hash useful for signatures and certificates, because a signed fingerprint then stands for exactly one document.

  • MD5 has had practical collisions since 2004. In 2008, researchers used MD5 collisions to create a fake certificate authority certificate, which is why browsers and certificate authorities stopped using it. Today a collision can be made in seconds on an ordinary computer.
  • SHA-1 held out longer. In 2017, Google and CWI Amsterdam published the first real collision, two different PDF files with the same SHA-1. Attacks have become cheaper since. Browsers stopped trusting SHA-1 certificates in 2017, and standards bodies are phasing it out.
  • SHA-256, part of the SHA-2 family, has no known practical attack on its collision resistance.

Notice what "broken" means here. An attacker cannot take any file and craft a different one with the same MD5, which would be a preimage attack. What they can do is make two files together, one harmless and one not, that share a hash. That matters whenever someone you do not trust can prepare both versions, as with signed documents, certificates and software updates. It matters much less when you are only looking for a damaged file.

The Hash Generator reflects this. MD5 and SHA-1 carry a "not for security" label, and a warning says they are still fine for checksums and detecting accidental corruption.

Which hash for which job

Job Choose Why
Verifying a download SHA-256 (or SHA-512) Strong; most projects publish it. See how to verify a download with its SHA-256 checksum
Spotting a corrupted or partial copy MD5 or SHA-256 Either finds accidents; MD5 is enough if that is all the site gives
Finding duplicate files MD5 or SHA-256 Identical files always share a hash
Cache keys and ETags MD5 or SHA-256 Nobody is attacking you
Signing API requests or webhooks HMAC-SHA-256 A secret key plus a strong hash
Digital signatures and certificates SHA-256 or stronger MD5 and SHA-1 are not acceptable
Matching an old system that demands MD5 or SHA-1 The one it needs Use it as asked, and treat the result as a label, not a safeguard
Storing passwords None of them Use Argon2id, bcrypt or scrypt

If a table cell says "MD5 or SHA-256", choose SHA-256 unless something requires MD5. It costs you nothing, and it avoids an argument later.

Why none of them is right for passwords

MD5, SHA-1 and SHA-256 are all designed to be fast. That is a virtue for checking a file and a disaster for storing a password. If a site's database leaks, an attacker can try billions of guesses a second against fast hashes. The Password Strength Checker's offline scenario shows this: it assumes 10 billion guesses a second against a fast hash such as MD5. A password like Password1! rated Very weak there, with a crack time of less than a second.

Password storage should use a deliberately slow, salted algorithm, such as Argon2id, bcrypt or scrypt. To test how your own password would stand up, try the Password Strength Checker. If you want to see what a plain hash of a password looks like, type a harmless test word into the Hash Generator.

How to compare the three yourself

  1. Open Hash Generator.
  2. Type hello into the box labelled "Text (hashed as UTF-8)". The five rows appear, from MD5 to SHA-512.
  3. Change the text to Hello. Every hash changes completely.
  4. Paste one of the old values, for example the MD5 5d41402abc4b2a76b9719d911017c592, into "Compare with expected hash (optional)". Because the text is now Hello, the page answers "No match with any hash of this text" and adds that the length fits MD5.
  5. Change the text back to hello and the green "Match" note appears on the MD5 row.

To hash a file instead, choose File as the Input type. MD5 works on any size. The SHA rows work up to 500 MB.

Common mix-ups

Does a longer hash mean more secure?

Not by itself. SHA-1 is longer than MD5, yet both are broken. Strength depends on the design, not just on the length. Among the SHA-2 family, SHA-256 and SHA-512 are both considered safe.

Is SHA-256 the same as "encryption"?

No. A hash cannot be undone, and there is no key to unlock it. Encryption is reversible with a key. They solve different problems.

Can I "decrypt" an MD5 hash?

Not by calculation. Websites that offer this only look the hash up in a table of known inputs, which works for short common words and fails for anything else. That is also why unsalted MD5 passwords are risky.

Why do I still see MD5 everywhere?

Because it is fast, universal and good enough for non-security jobs. Many download pages list an MD5 next to a SHA-256. Use the SHA-256 when you can.

Quick checklist

  • Default to SHA-256, and use HMAC-SHA-256 when you need a secret key.
  • Use MD5 or SHA-1 only for legacy systems and accident checks.
  • Never use any of the three as a password store.
  • Remember that a matching hash only proves two files are identical, not that either one is trustworthy.
  • For more detail on each algorithm, see the MD5 guide and the SHA-256 guide.

Frequently asked questions

Which is better, MD5, SHA-1 or SHA-256?
SHA-256. It has no practical collision attack, while MD5 and SHA-1 both have. Use MD5 or SHA-1 only when a system forces you to, or for checks where nobody is attacking you, such as finding duplicate files.
Is MD5 still safe for checking a download?
It is fine for catching a damaged or incomplete file. It does not prove the file is genuine, because someone who can replace the file can often replace the hash too, and MD5 collisions can be made on purpose. Prefer the SHA-256 checksum when the publisher offers one.
Is SHA-256 slower than MD5?
Slightly, but for files and short text you will not notice the difference. Speed is not a reason to choose MD5, and it is a reason not to hash passwords with either.
Can I store passwords as MD5, SHA-1 or SHA-256?
No. All three are very fast, which helps an attacker try billions of guesses a second against a stolen database. Store passwords with a slow, salted algorithm such as Argon2id, bcrypt or scrypt.
Why does the Hash Generator show SHA-384 and SHA-512 as well?
They belong to the same SHA-2 family as SHA-256 and some systems ask for them. They are just as safe, with longer outputs of 96 and 128 hex digits.
Found this useful? Share it

Tools in this guide

Main tool

Hash Generator

Calculate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text or file at once, create HMACs with a secret key,.

Open tool

MD5 Generator

Calculate the MD5 hash of text or files of any size and check downloads against a published MD5 checksum — with SHA-1.

Open tool

SHA256 Generator

Get the SHA-256 hash of any text or file in hex or Base64, sign messages with HMAC-SHA256,.

Open tool

Password Strength Checker

See how long your password would really take to crack.

Open tool

Back to all guides & blog