MD5 vs SHA-1 vs SHA-256 vs SHA-512: which hash to use

By Hammad Rasool · November 11, 2026

Quick answer: use SHA-256 for checksums, signatures, cache keys and anything new. MD5 and SHA-1 are broken for security because people can create two different inputs with the same hash; keep them only for non-security uses such as spotting accidental file corruption, or for compatibility with an old system. For passwords, use none of these: use a deliberately slow password hash such as Argon2id, scrypt, bcrypt or PBKDF2. You can compute every hash on this page with the hash generator.

How this was tested: on 11 November 2026 the hash generator's code was run on seven inputs, including an empty string, Urdu text, an accented word and an emoji, and every MD5, SHA-1, SHA-256 and SHA-512 result matched Node.js's built-in crypto module; the MD5 and SHA-256 results for the non-English inputs also matched Python's hashlib. Speeds were measured in Node.js 24 on one Windows laptop by hashing 256 MB with each algorithm. They show the relative cost on that machine, not a benchmark.

MD5 vs SHA-1 vs SHA-256 vs SHA-512

AlgorithmOutputMeasured speedSecurityUse for
MD5128 bits (32 hex)807 MB/sBroken: collisions are practicalNon-security checksums only
SHA-1160 bits (40 hex)1,077 MB/sBroken: a real collision was published in 2017Legacy systems only
SHA-256256 bits (64 hex)506 MB/sNo practical attack knownThe default choice
SHA-512512 bits (128 hex)775 MB/sNo practical attack knownLonger output; often fast on 64-bit CPUs

On this machine SHA-1 was the fastest and SHA-512 beat SHA-256. Speed depends on the CPU and on hardware support for each algorithm, so "MD5 because it's faster" is not a reason to pick it: SHA-256 hashed about half a gigabyte a second, which is fast enough for nearly any job.

What a hash is, in one paragraph

A hash function turns any input into a fixed-length fingerprint. The same input always gives the same hash, a tiny change gives a completely different one, and you can't get the input back from the hash. Changing one letter's case changed every part of the SHA-256 result:

SHA-256("hello")  2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-256("Hello")  185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

What "broken" means for MD5 and SHA-1

A secure hash must make it infeasible to find two different inputs with the same hash (a collision). For MD5 that has been practical for years: RFC 6151 says MD5 should not be used where collision resistance is needed. For SHA-1, Google and CWI Amsterdam published two different PDF files with the same SHA-1 hash in 2017 (the "SHAttered" attack), and NIST has announced that SHA-1 should be phased out by the end of 2030.

What that means in practice:

  • Don't use MD5 or SHA-1 for digital signatures, certificates, verifying downloads someone could tamper with, or deduplicating files an attacker can upload.
  • They are still fine for detecting accidental changes, such as checking that a file copied from a USB drive arrived intact, or as a quick cache key, where nobody is trying to fool you.
  • If a system gives you only an MD5 checksum for a download, it protects against a broken download, not against a tampered one.

Never store passwords with MD5, SHA-1 or SHA-256

General-purpose hashes are designed to be fast, which is exactly wrong for passwords: an attacker with your database tries billions of guesses, and each guess costs one hash. Measured on the same laptop, in one thread:

SHA-256 of short strings      about 450,000 per second
scrypt (N=2^17, r=8, p=1)     253 ms per hash  (about 4 per second)
PBKDF2-SHA256, 600,000 rounds 221 ms per hash  (about 4.5 per second)

The scrypt and PBKDF2 settings above are the minimums in OWASP's Password Storage Cheat Sheet. Each guess cost roughly 100,000 times more than a plain SHA-256, and dedicated cracking hardware makes the gap for plain hashes far worse. OWASP recommends Argon2id first, then scrypt, bcrypt or PBKDF2, always with a unique random salt per password; the password libraries for each language handle the salt for you. Use them instead of building this yourself.

The hash generator also shows NTLM, the format Windows uses for local account passwords: MD4 of the password encoded as UTF-16LE, with no salt. NTLM("password") came out as the widely published 8846F7EAEE8FB117AD06BDD830B7586C. It is there for administrators and security testers who need to compare values, not as a way to store passwords.

Why your hash doesn't match someone else's

A hidden line break

$ printf 'hello' | sha256sum
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824  -

$ echo "hello" | sha256sum
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03  -

echo adds a line break, so it hashed hello\n, not hello. Use printf, or echo -n where supported. A file saved with a final newline has the same problem.

Text encoding

Hashes work on bytes, not characters. The generator encodes text as UTF-8, as do Node.js and Python by default, which is why all three gave the same result for کراچی and Café. A program that uses another encoding (Windows code pages, UTF-16) will produce a different hash for the same visible text.

Upper and lower case hex

8846F7EA... and 8846f7ea... are the same hash written differently. Compare them case-insensitively.

Test vectors to check any tool

These results came out identical in the generator, Node.js and Python:

MD5("")          d41d8cd98f00b204e9800998ecf8427e
MD5("abc")       900150983cd24fb0d6963f7d28e17f72
SHA-1("abc")     a9993e364706816aba3e25717850c26c9cd0d89d
SHA-256("abc")   ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
NTLM("password") 8846F7EAEE8FB117AD06BDD830B7586C

If a tool or library gives different values for these inputs, it is encoding the text differently or adding characters.

Which hash to use: a short decision list

  • Password storage: Argon2id, scrypt, bcrypt or PBKDF2. Never a plain hash.
  • File integrity against tampering, signatures, tokens: SHA-256 (or SHA-512). For a message authentication code, HMAC-SHA256 with a secret key.
  • Accidental-corruption checks and cache keys: SHA-256 by default; MD5 is acceptable if a system requires it.
  • Matching an existing system (an old API, a Git object ID, a checksum file): whatever it uses.
  • Unique IDs: not a hash at all; use a UUID from the UUID generator.

FAQ

Is MD5 encryption?

No. Encryption can be reversed with a key; a hash can't be reversed at all. "MD5 decrypt" sites only look the hash up in tables of common inputs, which is another reason not to hash passwords with it.

Is SHA-256 still secure in 2026?

No practical collision or preimage attack on SHA-256 is publicly known, and it is what NIST and most protocols use today. The weakness is using it for passwords, not the algorithm.

Is SHA-512 more secure than SHA-256?

It has a longer output and a larger security margin, and on this 64-bit laptop it was faster. SHA-256 is already far beyond practical attack, so choose based on what the system you work with expects.

Is my text sent anywhere when I use the hash generator?

No. Hashes are computed in your browser.

Sources