QuickieTool

How to check a downloaded file is the one you were meant to get

By Muhammad Zaheer, QuickieTool6 min read

You download an installer and notice a long string of letters and numbers printed next to the link, labelled SHA-256 or checksum. Almost everybody ignores it. It is the only mechanism most download pages offer for confirming that the file you received is the file the publisher intended to send.

What a hash actually is

A hash function takes a file of any size and produces a fixed-length string from it. The same file always produces the same string, and a different file essentially never produces the same one.

The important property is sensitivity. Change a single byte anywhere in a hundred-megabyte file and the resulting hash is completely different — not slightly different, but unrecognisably so. There is no partial match and no near miss, which is what makes comparison trivial: the strings match or they do not.

It is also one-way. You cannot reconstruct a file from its hash, which is why publishing one alongside a download gives nothing away.

The two things it catches

The first is corruption. Downloads fail in ways that are not always obvious — a dropped connection resumed badly, a full disk, storage that has degraded. A file can appear complete and still be damaged, and the symptom is usually an installer that fails cryptically much later. Comparing hashes turns that into an immediate, definite answer.

The second is tampering. If a download server is compromised, or you fetched the file from a mirror rather than the original, the file you received may not be the file that was published. As long as you obtain the expected hash from a source you trust more than the file source, a match tells you the contents are exactly what the publisher produced.

That qualification is the entire point, and it is where people go wrong. A hash published on the same compromised page as the file proves nothing, because whoever replaced the file could replace the hash beside it. The hash needs to come from somewhere the attacker did not control.

Generate a hash for any file and compare it against a published checksum. Runs in your browser, so the file never leaves your device.

Generate a file hash

Which algorithm you are looking at

  • SHA-256: the current sensible default, and what most projects publish
  • SHA-512: longer, equally fine, sometimes preferred for large files
  • SHA-1: outdated. Adequate for spotting corruption, not for detecting deliberate tampering
  • MD5: long broken for security purposes, still occasionally published, still useful only as a corruption check

If a site offers several, use the strongest. If it only offers MD5, treat a match as evidence the download completed correctly and not as proof nobody interfered with it.

How to check one

  1. Copy the published checksum before you download, and note which algorithm it is.
  2. Download the file.
  3. Generate a hash of the downloaded file using the same algorithm.
  4. Compare the two strings.
  5. If they differ, delete the file and download it again rather than trying to use it.

Compare properly rather than eyeballing the first and last few characters, which is exactly the shortcut a deliberate attacker would rely on. Paste both into a text editor one above the other, or use a comparison tool. A mismatch anywhere means a mismatch.

When it is worth the effort

For a photograph a colleague sent, this is overkill. For anything you are about to execute on your machine — an installer, a disk image, a firmware update, a virtual machine — it is a reasonable habit, and it takes under a minute.

It is most valuable when the file came from anywhere other than the publisher's own site: a mirror, a file-sharing link, a colleague's copy, a download that redirected somewhere unexpected. That is precisely the situation the checksum was designed for.