Checksums: verifying downloads with SHA-256
What a hash proves, how to check a download on any system, and why a matching checksum is not the same as authenticity.
Next to many software downloads, such as Linux ISOs, installers, firmware, and database dumps, there is a long string of letters and digits labelled SHA-256. It lets you check that the file you have is exactly the file that was published, byte for byte. Checking it takes seconds, and it catches both corrupted downloads and tampered files, provided you understand what the check does and does not prove.
What a hash is
A cryptographic hash function turns any amount of data into a fixed-size fingerprint. SHA-256 always produces 256 bits, written as 64 hexadecimal characters. Three properties make it useful:
- Deterministic: the same input always gives the same hash, on any computer.
- Avalanche effect: changing one bit of the input changes about half the bits of the output. “hello” and “Hello” have completely unrelated hashes.
- Collision resistance: finding two different inputs with the same SHA-256 hash is computationally infeasible.
SHA-256("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-256("Hello") = 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
SHA-256("hello\n") = 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03The last line explains a very common mismatch: echo hello adds a newline, so hashing its output is not the same as hashing the five characters. Hash text hashes exactly the characters you type, with nothing added.
Verifying a download
- Download the file, and copy the published SHA-256 value from the project’s official website or release page.
- Open hash file, choose the file, and keep SHA-256 selected.
- Paste the published value into the comparison field.
- A match means your file is identical to the one the publisher hashed. A mismatch means it is not. Download again, preferably from the official source.
The same check on the command line:
- Linux:
sha256sum file.iso - macOS:
shasum -a 256 file.iso - Windows PowerShell:
Get-FileHash file.iso(SHA-256 by default)
All of these produce the same value. Letter case does not matter: uppercase and lowercase hex represent the same bytes.
Integrity is not authenticity
A matching checksum proves that the file matches the checksum. It does not prove who made either one. If an attacker compromises a download mirror, they can replace both the file and the checksum shown next to it. That has happened to real projects. For stronger assurance:
- Get the checksum from a different channel than the file, for example the project’s main HTTPS website rather than the mirror.
- Verify a cryptographic signature when one is published, such as a GPG signature on the checksum file, Sigstore, or code signing on Windows and macOS installers. A signature ties the file to the publisher’s key.
- Prefer package managers, which verify signatures and checksums automatically.
Which algorithm?
SHA-256 is the standard choice for file integrity today. SHA-384 and SHA-512 are also secure and appear in some publishers’ release notes. Use whichever the publisher lists, since you can only compare like with like. MD5 and SHA-1 have practical collision attacks, meaning two different files can be crafted with the same hash, so they only guard against accidental corruption, not deliberate tampering. The tools here offer SHA-256, SHA-384, and SHA-512.
Other everyday uses
- Checking copies and backups: equal hashes mean identical files, regardless of names or dates. To find where two files differ, use file compare.
- Deduplicating files: files with the same hash are duplicates.
- Content Security Policy: CSP hash sources are the Base64 of a script’s SHA-256 digest.
- Subresource Integrity: the
integrityattribute on script tags pins a CDN file to a specific hash.
Hashes are not for passwords
SHA-256 is designed to be fast, which is exactly wrong for passwords. An attacker with a stolen database can try billions of guesses per second. Password storage needs a slow, salted algorithm designed for the job, such as Argon2id, scrypt, or bcrypt. A hash is also not encryption: nothing can be “decrypted” from it, and short or predictable inputs can be found by guessing.
