fixmint

MD5, SHA-1 or SHA-256: which hash to use for downloads

By · · 4 min read

For checking a download, use SHA-256 or SHA-512 whenever the publisher offers one. MD5 and SHA-1 still catch accidental damage, such as a cut-off download, but researchers have shown that two different files can be made to share an MD5 or SHA-1 hash. A match from those algorithms therefore cannot prove that a file is the one the publisher made. A hash is a fingerprint, not encryption, and it means something only when it comes from a source you trust.

Hash generatorDoes my download match?Open

What a hash does, and does not

A hash function turns data of any size into a fixed-length fingerprint. The same input always gives the same fingerprint, and changing one byte gives a completely different one. That makes a hash useful for comparison: if the fingerprint of your copy matches the published one, the two files are almost certainly identical.

A hash is not encryption. It cannot be reversed to recover the file, and it uses no key. It hides nothing, and by itself it proves nothing about who made the file. A checksum is simply a hash that a publisher prints beside a download so you can compare.

The four common options

AlgorithmOutput lengthUse it for
MD5128 bits, 32 hex charactersSpotting accidental damage only
SHA-1160 bits, 40 hex charactersLegacy checks; avoid for security
SHA-256256 bits, 64 hex charactersThe usual choice for downloads
SHA-512512 bits, 128 hex charactersThe same family, with longer output

Why MD5 and SHA-1 are not enough

A collision means two different inputs with the same hash. Collisions in MD5 have been known since 2004. In 2017 researchers published a practical SHA-1 collision, two different PDF files that share one hash.

For a download, this matters because an attacker who controls a file can produce a malicious version with the same MD5 or SHA-1 hash as the genuine one. If a publisher lists only MD5 or SHA-1, a match no longer proves the file is genuine. The hash generator's own FAQ makes the same point: use SHA-256 or SHA-512 for anything security related.

No practical SHA-256 collision is known at the time of writing, which is why SHA-256 is the usual choice. The SHA-256 checksum guide walks through the steps.

Choose the right one

  1. If the publisher offers SHA-256 or SHA-512, use that, and set MD5 and SHA-1 aside for security.
  2. If only MD5 or SHA-1 is offered, check it anyway. It still catches a corrupted or incomplete download. Treat a match as "not damaged", not as "genuine".
  3. If no hash is offered, you cannot check integrity this way. Download from the official page over HTTPS, and where the project publishes signed checksum files, check the signature.

The hash generator computes MD5, SHA-1, SHA-256, SHA-384 and SHA-512 at once, for text or for one file. The file is read in your browser and nothing is uploaded. Paste the publisher's hash into Expected hash. The tool removes spaces and ignores capitals before comparing, so a hash printed in upper case or in groups still matches. Very large files can strain browser memory, in which case use a command-line tool such as sha256sum on Linux, or shasum -a 256 on a Mac.

What a match tells you

A matching hash means your copy is almost certainly identical to the file that was hashed. It does not say who did the hashing, or that the hashed file was the one the publisher intended to ship. For that, the source matters more than the algorithm. If the hash came from the publisher's own release page, and you reached that page directly rather than through a link in a message, a match is strong evidence. If the hash came from a comment, a mirror or a forum, treat it as unverified until you find it on a trusted page.

A checksum needs a trusted source

A checksum that sits on the same server as the file proves only that the copy matches what that server holds. If an attacker replaces the file, they can replace the checksum beside it. A checksum helps when it comes from somewhere separate, such as the project's signed release notes, or a page you reached independently of the download link.

Hashes for passwords are different

Password storage also uses hashing, but it needs a slow hash designed for passwords, with a unique salt for each one. A fast hash such as SHA-256 is the wrong tool there. For downloads, the job is comparison, and SHA-256 does it well.

Edge cases

  • Case. Hex letters A to F are the same in either case, so compare without caring about capitals.
  • Truncated hashes. Some sites print only the start of a hash. A short match proves little, so compare the whole value.
  • Several files. Some projects publish one checksum file for a whole release. Find the line with the exact file name, because a match on another file's line proves nothing.
Cover of How to Remain Valuable When Intelligence Becomes CheapHow to Remain Valuable When Intelligence Becomes Cheap

224 pages on the human, economic and strategic advantages that stay scarce when AI can do most cognitive work.

$3.84 Get it on Gumroad →