MD5 vs SHA-256: What Hashes Prove and Which to Use

2026-10-145 min readEncryption5 tools covered

A vendor publishes a SHA-256 checksum for a download - how do you actually use it? Why can't you "decrypt" a hash? And is MD5 still usable in 2026? All three answers follow from what a hash function can and cannot prove.

Key takeaways
  • Hashes are one-way - recovering the input from a digest requires brute force, so "decrypting a hash" does not exist
  • Output lengths differ by algorithm: MD5 is 32 hex characters, SHA-1 is 40, SHA-256 is 64, SHA-512 is 128
  • MD5 and SHA-1 are broken for adversarial uses such as signatures and certificates, but remain adequate for detecting accidental corruption
  • The same input always produces the same digest, and changing a single byte changes the entire output
  • Storing a bare hash is still unsafe for passwords: unsalted MD5 falls to a rainbow table instantly, so passwords need a per-user salt and a deliberately slow algorithm

#What a hash actually proves

A hash function compresses data of any length into a fixed-length digest, and the process cannot be reversed. Three properties follow from that:

  1. Deterministic - the same data always produces the same digest. Change one byte and the entire output changes.
  2. One-way - you can compute a digest from the input, never the input from the digest. So-called "hash cracking" is dictionary lookup: hash candidates and compare. It is brute force, not mathematics.
  3. Collision-resistant - it should be infeasible to find two different inputs with the same digest. How strong that guarantee is separates MD5 from SHA-256.

That is why a checksum answers exactly one question: *is this the same data I expected?* Did the download complete, did the transfer corrupt anything.

#Digests and their lengths

Length is your quickest sanity check - if a value is 32 characters, no SHA-256 produced it.

AlgorithmOutputHex lengthStatus in 2026
MD5128 bits32 charsCollisions constructible; integrity checks only
SHA-1160 bits40 charsCollisions constructible (SHAttered, 2017); avoid for new work
SHA-256256 bits64 charsNo practical collisions; the default choice
SHA-512512 bits128 charsStronger but longer; rarely necessary
Warning

MD5 must not be used for digital signatures, certificates, code signing, or any tamper protection against a motivated attacker. Colliding file pairs can be constructed deliberately, so a matching MD5 proves nothing. It is still fine for detecting accidental corruption, because those errors are random rather than crafted.

#Verify a download in three steps

  1. Open SHA Hash, or MD5 Hash if the publisher only provides MD5.
  2. Drop the file into the upload area. It is read and hashed locally in your browser, so the file is never uploaded.
  3. Compare against the published checksum character by character. Partial matches mean nothing.
Tip

Never compare hashes by eye. A single differing character means a completely different dataset, so put both strings side by side with the Text Diff tool instead of scanning them manually.

On the command line you should get an identical result:

Shell
# macOS / Linux
shasum -a 256 package.tar.gz
md5sum package.tar.gz

# Windows PowerShell
Get-FileHash package.tar.gz -Algorithm SHA256

#Why salting is not optional for passwords

Unsalted hashes fail for passwords because the input space is tiny, not because the algorithm is weak. Common passwords number in the hundreds of thousands, so an attacker can precompute a plaintext-to-digest table (a rainbow table) and look up any hash in milliseconds.

Salting prepends a unique random string per user before hashing, so identical passwords produce unrelated digests across accounts and sites:

Storage schemeWhat an attacker does after a database leakVerdict
md5(password)Rainbow table lookup; common passwords fall instantlyUnusable
md5(password + one global salt)One break covers the whole siteNot enough
md5(password + per-user salt)Must brute force each user individuallyBetter, but MD5 is still too fast
bcrypt / scrypt / Argon2Algorithm is deliberately slow, brute force becomes expensiveRecommended
Key point

What matters is not which hash you pick but how slow it is. MD5 and SHA-256 are optimized for speed, which is precisely the wrong property for password storage. Use bcrypt, scrypt or Argon2 with a tunable cost factor.

#A UUID is not a hash

These two appear together often and are unrelated:

  • A hash is a digest of existing data. Same input, same output, fixed length.
  • A UUID is a generated identifier with no input. Use UUID / GUID Generator to assign unique IDs to database rows, sessions or requests.

Need a unique identifier? Use a UUID. Need to detect whether data changed? Use a hash. Using a hash as an ID brings two problems: collisions are theoretically possible, and if the ID is derived from user input it becomes predictable.

#Cheat sheet

GoalToolNote
Verify a downloaded fileSHA Hash, pick SHA-256Compare against the published digest
Legacy system expects MD5MD5 HashFine for compatibility, do not introduce it in new code
Sign API requestsSHA-256 or strongerPair it with a secret key (HMAC); a bare hash proves nothing
Store user passwordsbcrypt / scrypt / Argon2Do not run real passwords through an online tool
Generate unique IDsUUID / GUID GeneratorNot a hash
Encode data for transportBase64 Encoder / DecoderAlso not a hash, and reversible

#Frequently asked questions

#Can a hash be decrypted?

No, and "hash decryption" does not exist as an operation. Sites claiming to decrypt MD5 work by storing a huge lookup table of plaintext-to-digest pairs. Your hash is shown as plaintext only if it is already in the table. Short, common passwords "decrypt" because they are in the dictionary, not because the algorithm was broken.

#Is MD5 still usable at all?

It depends on the threat model. For integrity against accidental corruption - truncated downloads, damaged transfers - it works, because those failures are random. For anything adversarial - signatures, certificates, tamper protection, password storage - it does not, because collision attacks are public and practical.

#Why do I get a different hash for the same file on Windows and Linux?

Suspect the file first. Text-mode transfers on Windows rewrite \n to \r\n, which changes the bytes and therefore the digest. Re-transfer in binary mode. More rarely, two commands default to different algorithms - pass the algorithm explicitly to be sure.

#Is SHA-256 much slower than MD5?

Not in any way that matters for everyday use. On modern CPUs SHA-256 is roughly twice as slow, which on a tens-of-megabytes file is still a matter of milliseconds to a few hundred. Choose on security grounds, not speed.

#Does a longer hash always mean better security?

Up to a point. SHA-512 has a longer digest and a higher theoretical strength, at the cost of longer values to store and transmit. SHA-256 is the practical default, and going longer is rarely necessary outside specific compliance requirements.

Tools used in this guide

Related guides