To verify a download, compute its checksum on your machine and compare it with the value the publisher lists. Use SHA-256 whenever it is offered; MD5 is only acceptable for catching accidental corruption. A matching checksum proves the file is intact, but it does not prove the file is genuine unless the checksum came from a source you trust separately.

What a checksum is

A checksum, in this context a cryptographic hash, is a fixed-length fingerprint of a file's contents. The same bytes always give the same digest, and changing even a single bit gives a completely different one. This lets you confirm that what you received is bit-for-bit what was published, whether the difference comes from a dropped connection, a bad disk sector or deliberate tampering.

What a checksum proves, and what it does not

This distinction is the most misunderstood part. A checksum proves integrity: the file you hold matches the file the checksum was calculated from. It does not prove authenticity: that the file came from the legitimate author.

Consider an attacker who compromises a download server. They replace the installer and, because the checksum is on the same page, replace that too. Your verification passes and the file is still malicious. A checksum is only as trustworthy as the channel that delivered it. It is most useful when it comes from a different, trusted location than the file itself, such as the project's main site while the file is served from a mirror.

MD5 versus SHA-256

PropertyMD5SHA-256
Digest length128 bits (32 hex characters)256 bits (64 hex characters)
Collision resistanceBrokenNo practical attacks known
Catches accidental corruptionYesYes
Resists deliberate tamperingNoYes
Recommended todayOnly for non-security checksYes, the sensible default

MD5 collisions are practical: researchers have shown that two different files can be crafted to share the same MD5 digest. That means someone who controls a file's contents in advance can, in some situations, produce a malicious variant with a matching MD5. Random corruption is a different matter. A flipped bit during transfer will change an MD5 digest just as reliably as a SHA-256 one, so MD5 still works as a quick error check. But since SHA-256 costs almost nothing extra on modern hardware, there is little reason to choose MD5 when both are available.

When each algorithm is reasonable

Use SHA-256 for software downloads, disk images, backups you want to trust and anything else where tampering is conceivable. MD5 survives mainly in legacy systems, some storage services that report it as an ETag, and quick duplicate detection. If a publisher lists several digests, always prefer the strongest one. If they list only MD5, the check still catches a broken download, but treat it as weaker evidence and look for a signature as well.

How to compute a checksum

macOS and Linux

shasum -a 256 ubuntu.iso      # macOS and most Linux
sha256sum ubuntu.iso          # Linux (GNU coreutils)
md5 ubuntu.iso                # macOS
md5sum ubuntu.iso             # Linux

Windows

Get-FileHash .\ubuntu.iso -Algorithm SHA256    # PowerShell
certutil -hashfile ubuntu.iso SHA256            # Command Prompt
certutil -hashfile ubuntu.iso MD5

If you would rather not use the command line, the checksum generator computes MD5 and SHA-256 for a file you upload. The file is processed on our server and deleted automatically, so use the command line instead for anything confidential.

Worked example: hashing "hello"

Hashing the five bytes hello (no trailing newline) gives these digests:

MD5:     5d41402abc4b2a76b9719d911017c592
SHA-256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

You can reproduce them with printf hello | shasum -a 256 and printf hello | md5. Note the use of printf rather than echo: echo hello adds a newline character, which is a different input and produces a completely different SHA-256 digest (5891b5b5...). This is a good illustration of how sensitive hashes are, and a common reason a hand-made check fails.

Comparing safely

  • Copy and paste the published checksum rather than retyping it. Transcription errors are easy with 64 hex characters.
  • Compare the entire string, not just the first and last few characters. Partial matches are weaker evidence, and a deliberate attacker can aim for a similar-looking prefix.
  • Ignore case: hex digits are the same whether written in upper or lower case.
  • Let a tool do the comparison where possible, for example echo "<digest> file" | shasum -a 256 -c, which prints OK or FAILED.
  • Obtain the checksum from a trusted, preferably separate, source over HTTPS.

Signatures: the stronger option

To prove who published a file, you need a digital signature. Many projects publish a detached GPG signature alongside the file. You import the maintainer's public key, ideally confirming its fingerprint through an independent channel, and run gpg --verify file.sig file. A valid signature shows that the file was signed by the holder of that private key and has not changed since. This closes the gap that a plain checksum leaves open, because an attacker who replaces the file cannot forge the signature without the private key.

Common mistakes

  • Trusting a checksum that sits next to the file on the same compromised server.
  • Using MD5 where an adversary could have crafted the file.
  • Hashing the wrong thing, such as the compressed archive versus the extracted file, or text with an unexpected trailing newline.
  • Comparing only a few characters of the digest.
  • Confusing hash algorithms: a 64-character digest is not MD5, and a 32-character one is not SHA-256.

Frequently Asked Questions

Is MD5 still safe to use?

Only for detecting accidental corruption. It should not be used where someone might deliberately craft a file, because MD5 collisions can be produced.

Does a matching checksum mean the file is safe?

No. It means the file matches whatever the checksum was computed from. If the source of the file was malicious, a match tells you nothing about safety.

Why does my checksum not match?

The usual causes are an incomplete or corrupted download, hashing a different file or format than the publisher did, or a different algorithm. Download again and check the algorithm name.

Is SHA-256 the same as encryption?

No. Hashing is one-way and has no key. You cannot recover the file from its digest. For a related distinction, see how Base64 differs from encryption.