md5check

Checksum verification

Downloading a file and comparing its hash is half the job. The other half is knowing that the hash you compared against wasn't replaced along with the file. This guide is about that gap.

Updated October 2026 9 min read Level: intermediate

Three things that get confused

AnswersNeeds
Checksum (hash) Are these the same bytes? Nothing but the file
HMAC Did someone holding the shared key produce this? A shared secret
Signature Did the holder of this private key produce this? A public key you already trust

A checksum is a fingerprint. A signature is a fingerprint plus a notarised statement of who took it. Publishing a checksum next to a download raises the bar for an attacker from "replace the file" to "replace the file and the checksum" — which is usually the same amount of work.

The substitution problem

Consider a compromised download server. The attacker replaces installer.exe and also edits the page that lists its SHA-256. A user who downloads both and compares them gets a match, and a false sense of security. Nothing about the hash algorithm helps here; SHA-512 would fail exactly the same way.

Two things break that attack:

  • Get the checksum from a different channel. The release announcement on a mailing list, a package repository, a signed Git tag, a vendor's separate status page.
  • Have the checksum signed by a key you already trust. Then a modified checksum fails verification even if the attacker controls the server.

Verifying a GPG signature

Most serious projects publish three things: the artifact, a checksum file, and a signature over the checksum file. The workflow is:

# 1. fetch the artifact, the checksum file and the signature
# 2. import the publisher's public key (once, from a source you trust)
gpg --keyserver keyserver.ubuntu.com --recv-keys 0xABCDEF0123456789

# 3. check the signature over the checksum file
gpg --verify tool-1.4.2.tar.gz.sha256.sig tool-1.4.2.tar.gz.sha256

# 4. only if step 3 says "Good signature", verify the artifact
sha256sum -c tool-1.4.2.tar.gz.sha256

Order matters. Verifying the signature after you have already trusted the checksum defeats the purpose: the attacker's checksum file would pass the hash comparison and you would never reach the signature check.

The weak link is step 2. If you fetch the public key from the same compromised server, you have verified that the attacker signed the attacker's file. Get the key fingerprint from an independent source — the project's documentation, a conference talk, a colleague who has verified it before.

What good publishing looks like

If you ship software, this is the baseline that lets your users actually verify something:

  1. Publish the artifact over HTTPS, plus a .sha256 file in sha256sum format.
  2. Sign the checksum file, not each artifact — one signature covers the whole release.
  3. Name the algorithm in the filename: foo-1.2.tar.gz.sha256, not foo-1.2.tar.gz.md5 with a SHA value inside.
  4. Put the same digest in the release notes, in text, so it can be compared without downloading a file.
  5. Keep the old releases' checksums online. People verify old versions all the time.
  6. Do not regenerate the artifact after publishing the checksum without republishing both.

Automating it

Manual verification does not survive contact with a CI pipeline. Two patterns that do:

# verify every artifact in a checksums file, fail the build on any mismatch
sha256sum --check --strict SHA256SUMS

# pin a digest in your Dockerfile so a changed base image fails the build
FROM node:22-alpine@sha256:6f3d8b1a...

Pinning by digest is the strongest form of this: the image reference becomes immutable, so re-tagging upstream cannot silently change what you build against.

Common mistakes

  • Comparing checksums by eye. A transposed character is invisible at 64 characters. Use a tool that says match or no match — the verifier does exactly that.
  • Using MD5 for authenticity. Collisions make it forgeable. Use SHA-256.
  • Treating a match as a virus scan. A matching checksum means "same bytes as the publisher hashed", not "safe to run". A publisher can ship malware, and a compromised publisher will.
  • Verifying the checksum file instead of the artifact. It happens more than you would think, especially with similarly named files.
  • Skipping verification because the download "looked fine". Corruption is silent. That is the entire reason checksums exist.

Practical rule. For a random download, a checksum from the vendor's own page is a reasonable level of assurance against corruption. For anything you are about to run with elevated privileges, get the checksum from an independent channel or check a signature.

Doing it in the browser

The file checksum tool produces MD5, SHA-1 and SHA-256 locally in one pass, and the verifier compares a pasted value against a file without uploading it. Neither proves where the checksum came from — that part is still your judgement.