What is SHA-256 and how to verify a file's integrity

Understand what a SHA-256 hash is and learn how to verify a download's checksum on Windows, macOS, Linux or right in your browser.

You've downloaded an installer, an operating system ISO or a file a colleague sent you. How can you be sure it arrived intact, without getting corrupted along the way or swapped for a tampered version? The usual answer on the download page is a line of 64 letters and digits: the SHA-256 hash.

Checking that code takes less than a minute and keeps you from installing a broken or malicious file. For documents and installers up to a few hundred megabytes, the SHA-256 hash generator does the math right in your browser; for multi-gigabyte ISO images, your system's terminal is the more reliable route, and the commands are further down.

What is SHA-256?

SHA-256 is a cryptographic hash function from the SHA-2 family, standardized by NIST in FIPS 180-4. It takes any input, from a single word to a multi-gigabyte file, and always returns a 256-bit digest written as 64 hexadecimal characters. That digest works like a fingerprint of the content.

The hash of the word abc, for example, is always ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad, on any computer and in any program that implements the standard.

The four properties that matter

Then there's the avalanche effect: a tiny change to the input produces a completely different hash. Look at what changing one digit does:

TextSHA-256
pay $1007a238083115390ef848d56cfad893b4e940f08cdf218d2dcf7bb65c1aa319183
pay $90040b51ce3cfa4af5781785c5bb72dff3de47b803e6d0fc167781628ef45855555

The two results share no visible pattern. That's what makes hashes useful for detecting changes: alter a single byte anywhere in a file and the whole hash changes.

How to verify a file's integrity

The logic is always the same. Compute the hash of the file you have, then compare it with the hash published by the official source.

Integrity check flow: the SHA-256 hash computed from the downloaded file is compared with the hash published on the official siteDownloaded fileSHA-256Computed hashOfficial sitePublished hashCompare✓ Match: file is intact✗ Different: discard
If the two hashes are identical, the file is exactly what the author published. If they differ at all, delete it and download it again.
  1. Download the file and note the SHA-256 hash shown on the official page. Sometimes it comes in a separate file such as SHA256SUMS.
  2. Compute the hash of your download with one of the commands below. For files up to a few hundred megabytes, the online tool works too.
  3. Compare the two values. Upper and lower case don't matter, but all 64 characters must match.
  4. If they differ, don't open or install the file. Download it again, ideally straight from the official site.

Commands for each operating system

SystemCommand
Windows (Command Prompt)certutil -hashfile file.iso SHA256
Windows (PowerShell)Get-FileHash .\file.iso -Algorithm SHA256
macOSshasum -a 256 file.iso
Linuxsha256sum file.iso

On Linux, if the project ships a checksum file, sha256sum -c --ignore-missing SHA256SUMS checks the listed files that are in the folder and prints "OK" for each intact one. Without --ignore-missing, it also complains about every file on the list you didn't download. PowerShell shows the hash in uppercase, which makes no difference to the comparison.

One caveat: a hash only proves the file matches what was published. If an attacker controls the website, they can replace both the file and the hash. So read the hash from an official HTTPS page and, when the project offers one, verify the digital signature as well.

Hashing is not encryption

Encryption can be reversed by whoever holds the key; a hash can't be reversed by anyone. You don't "decrypt" a SHA-256. Don't confuse it with encodings like Base64 either, which only change how data is written and can be undone by anybody. Our guide on what Base64 is explains the difference.

"One-way", however, doesn't mean "impossible to guess". If the content is short and predictable, like a common password, anyone can hash candidates until one matches. That's why passwords call for purpose-built slow functions rather than a checksum, and why your best protection is a long, unique password. See how to create a strong password.

Compute the hash in your browser

If you'd rather not open a terminal, the SHA-256 hash generator hashes text and files directly in your browser without uploading anything. Paste the official hash into the comparison field and it tells you instantly whether the values match; there's also a tab for comparing two hashes you already have. Because the browser has to load the whole file into memory, it works well for files up to a few hundred megabytes. For a multi-gigabyte ISO, use the commands in the table above.

Frequently asked questions

Does renaming a file change its SHA-256 hash?

No. The hash is computed only from the file's content, byte by byte. The name, modification date and folder aren't part of the calculation, so you can rename a download and still verify it. Opening the file and saving it again, even with no visible changes, can alter bytes and change the result.

Why do all empty files have the same hash?

Because SHA-256 is deterministic: the same input always gives the same output, and "no bytes at all" is an input too. The hash of empty content always starts with e3b0c442. If a download produces it, the file arrived empty or the transfer failed.

What are the .asc, .sig or .gpg files next to SHA256SUMS?

They're digital signatures, usually OpenPGP, of the hash list itself. With the project's public key, a command such as gpg --verify SHA256SUMS.gpg SHA256SUMS confirms the list was published by whoever holds the private key. That covers the case where an attacker swaps both the file and its hash.

Where else is SHA-256 used?

In digital certificates and software or document signatures, it condenses the content being signed. In backup systems, it identifies duplicate files and blocks by their content. In Bitcoin, it powers a proof of work: miners search for a block whose hash falls below a target value, which takes billions of attempts.

References