The idea in one sentence
Hash the file you have, and compare the result to the hash the publisher posted. If the two match, your copy is byte-for-byte identical to the one they hashed. If they do not, something changed — and you now have to work out what.
Windows
Command Prompt. certutil is present on every Windows install
since XP, so this works on a locked-down machine with no extra tools:
certutil -hashfile "C:\Users\you\Downloads\ubuntu.iso" MD5
certutil -hashfile "C:\Users\you\Downloads\ubuntu.iso" SHA256
The output wraps the digest across lines. Copy it without the spaces, or use the browser tool below. Older Windows versions inserted spaces between pairs of characters — a space is not part of the hash.
PowerShell. Cleaner output and a proper object to work with:
Get-FileHash .\ubuntu.iso -Algorithm MD5
Get-FileHash .\ubuntu.iso -Algorithm SHA256 | Format-List
# compare against a known value, ignoring case
$expected = '9e107d9d372bb6826bd81d3542a419d6'
(Get-FileHash .\file.bin -Algorithm MD5).Hash -eq $expected.ToUpper()
-Algorithm accepts MD5, SHA1, SHA256, SHA384, SHA512 and, on newer builds,
SHA3-256 and SHA3-512.
macOS
md5 ubuntu.iso # prints: MD5 (ubuntu.iso) = 9e107d9d...
md5 -q ubuntu.iso # digest only, no filename
shasum -a 256 ubuntu.iso # SHA-256
shasum -a 256 -c ubuntu.iso.sha256 # verify a checksum file
md5 is the system tool; shasum is the Perl script that covers SHA-1,
SHA-256 and SHA-512. Both are preinstalled.
Linux
md5sum ubuntu.iso
sha256sum ubuntu.iso
# verify a checksum file: prints OK or FAILED per line
sha256sum -c ubuntu.iso.sha256
md5sum -c ubuntu.iso.md5
-c is the reason to prefer the command line over a web tool for bulk work: it
reads a checksum file with one line per file and reports each one. On a directory of a
thousand release artifacts, that is the whole job in one command.
Any platform, in the browser
If you would rather not open a terminal, the file checksum tool hashes a file locally and shows MD5, SHA-1 and SHA-256 at once. Then paste the published value into the verifier and it will tell you match or no match, including when the publisher used a different algorithm than you assumed.
Six reasons a checksum fails when the file is fine
Before you re-download 4 GB, rule these out. They are ordered by frequency.
- You hashed the wrong algorithm. The publisher listed SHA-256 (64 characters) and you generated MD5 (32). The mismatch is in the length, and it is visible at a glance.
- Wrong file. Download pages often carry several artifacts — installer, portable zip, checksum list. People routinely hash the checksum file itself, or the version from last month.
-
Text mode versus binary mode on Windows. Line ending translation changes the
bytes. When a checksum file marks an entry with
*, the publisher means binary mode; usemd5sum --binary -cif your environment is translating. -
A trailing newline in text. This only applies when you hash a string, not a
file.
echo hello | md5sumandprintf '%s' hello | md5sumgive different answers because one includes the newline. - The publisher regenerated the artifact. A rebuild after the checksum was posted produces a valid file with a stale digest. Cross-check the file size and the build date.
- Copy-paste mangled the value. A truncated digest, a smart quote, a non-breaking space, or a line break inserted mid-value. Compare lengths before comparing characters.
A checksum is not a signature. It tells you the bytes match the source of the checksum. If an attacker controls that source, a matching checksum is meaningless. See checksum verification for what closes that gap.
A worked example
You downloaded tool-1.4.2.tar.gz. The page says:
MD5: 4d186321c1a7f0f354b297e8914ab240
SHA256: 0c3f9d2a8f1b7e4c6a5d8f3b2e1a9c7d6b5e4f3a2d1c0b9a8f7e6d5c4b3a2918
Run md5sum tool-1.4.2.tar.gz. If it prints the same 32 characters, you are done:
the archive is intact. If it prints something else, check the file size against the download
page before assuming corruption — a truncated download usually shows a smaller size, which
confirms the cause immediately.
Note the two values in that example are deliberately fictional. Never compare against a checksum you found in a tutorial; use the one the actual publisher provides.