To verify a download, calculate the SHA-256 hash of the file you received and compare it with the SHA-256 value the publisher lists. If the two strings are identical, your file is exactly the one that was hashed: nothing was cut off, damaged or swapped on the way. If even one character differs, do not use the file. You can calculate the hash with a command on your computer or in your browser, and this article shows both, plus the mistakes that produce false alarms.
What a hash proves, and what it does not
A hash function reads a file of any size and returns a short fixed-length string. SHA-256 returns 64 hexadecimal characters. Change one bit of the file and the string changes completely. That makes it a fingerprint: equal fingerprints mean equal files, for all practical purposes.
So a matching hash proves integrity: the file you hold is identical to the one the fingerprint was made from. It does not prove that the file is safe, and it does not prove who made it. Both limits matter below.
Step 1: find the published hash
Good download pages list a checksum next to the file, often as a line of text, a small SHA256SUMS file, or a table. Copy it from the page. If the publisher only offers MD5 or SHA-1, you can still use it to catch accidental damage, but see the section on those algorithms.
Step 2: calculate the hash of your file
In your browser
Open the file hash checker, stay on the File tab and drop the file on the box. The page reads the file from your disk and calculates SHA-256, SHA-1, SHA-384, SHA-512 and MD5 on your device. The file is not uploaded. Paste the published value into "Compare with a hash". The tool recognises the algorithm from the length (64 characters is SHA-256) and shows "Match" or "Does not match". Capital letters, spaces and colons do not matter, and you can paste the whole line the command-line tools print.
Files up to 4 GB are accepted. Anything over 100 MB is read in one-megabyte slices with a progress bar and a Cancel button, which is slower, and every algorithm left ticked adds time, so untick the ones you do not need.
With a command
On macOS:
shasum -a 256 ~/Downloads/installer.isoOn Linux:
sha256sum installer.isoOn Windows, in PowerShell:
Get-FileHash .\installer.iso -Algorithm SHA256Or in the older Command Prompt:
certutil -hashfile installer.iso SHA256The macOS and Linux commands print the hash, two spaces and the file name. PowerShell prints a small table whose Hash column is in capital letters. That is the same value: case does not matter. For a huge file, a command is faster than a browser.
Step 3: compare, do not eyeball
Compare the whole string. Matching the first and last few characters is a habit that fails exactly when someone has tried to fool you. Paste the published value into the tool, or let the command do the comparing. When a download page ships a checksum file, sha256sum -c SHA256SUMS on Linux, or shasum -a 256 -c SHA256SUMS on macOS, reads every line and prints installer.iso: OK or installer.iso: FAILED for each file. On Linux, add --ignore-missing to skip files you did not download.
A test you can run in a minute
The SHA-256 of the three letters abc is:
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015adType abc on the Text tab of the checker and you will see it. Now run printf 'abc' | shasum -a 256 in a terminal: the same value. Run echo abc | shasum -a 256 instead and you get edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb, because echo adds a line break and the text is now four characters. That is the most common reason two people get different hashes for what looks like the same text. For files it shows up too: a text file saved with and without a final line break has two different hashes.
Why MD5 and SHA-1 are not for security
MD5 and SHA-1 are broken for one specific purpose: it is possible to deliberately build two different files with the same hash. Collisions in MD5 have been demonstrated since 2004, and the first public SHA-1 collision, two different PDF files with the same hash, was published in 2017. That means a hash from these algorithms cannot protect you from someone who prepares the file you will check.
They still catch accidental damage, such as a download cut short or a flipped bit on a bad disk, so a site that publishes only MD5 is not lying to you. If you have a choice, compare with SHA-256. For this reason the checker adds a short note under the results whenever MD5 or SHA-1 is among them.
Why the source of the hash matters more than the algorithm
If an attacker can replace the file on a download server, they can often replace the checksum on the same page. Then everything matches and tells you nothing. Prefer a hash that reaches you by a different route: a signed announcement, a package manager's own records, or a value read to you by the publisher. For software that ships with a digital signature, verify the signature as well, because a signature proves who made the file and a hash does not.
If it does not match
- Download again, preferably from the same official page. A cut-off download is the most common cause. Compare the file size too.
- Check the algorithm. A 64-character value is SHA-256, 40 is SHA-1, 32 is MD5.
- Hash the right thing. The published value is for the exact file offered, for example the compressed archive, not the files you extracted from it.
- Check the version and platform. A hash for the 64-bit Windows build does not match the macOS build.
- Remove stray characters. A line break or a trailing space added while copying from a document counts when you hash text.
If a fresh download from the official source still does not match, do not run it. If two text files should be identical and their hashes differ, compare them line by line to see what changed.
A short checklist
Get the hash from the publisher, calculate SHA-256 of the file you downloaded, compare the whole string, and treat anything else as a failure. Use MD5 and SHA-1 only to spot accidental damage, and verify a signature when one is offered.