Check a File's SHA-256 Hash on Mac, Linux and Windows
A published SHA-256 checksum only helps if you compare it. Here are the exact commands for each operating system, a one-step check against a checksum file, and code for Node.js and Python.
To check a SHA-256 hash, you compute the hash of the file you downloaded and compare it with the one the publisher lists. If even one byte differs, the hashes do not match. The Hash Generator hashes text and files in the browser, and its page explains which algorithm to use when. This guide covers the commands and code for checking downloads.
Check a SHA-256 hash on macOS
shasum -a 256 release.tar.gz
# 51b12eb838732b786b4d45c660a974ddf3860ae09084fd293fa6e5df46581a6c release.tar.gz-a 256 selects SHA-256; without it, shasum uses SHA-1. openssl dgst -sha256 release.tar.gz gives the same hash in a different layout.
Check a SHA-256 hash on Linux
sha256sum release.tar.gz
# 51b12eb838732b786b4d45c660a974ddf3860ae09084fd293fa6e5df46581a6c release.tar.gzMany projects publish a file such as SHA256SUMS with one line per download. Check every file listed in it in one step:
sha256sum -c SHA256SUMS # Linux
shasum -a 256 -c SHA256SUMS # macOS
# release.tar.gz: OKThe check prints OK or FAILED per file and exits with an error code when any file fails, so it also works in scripts and CI.
Check a SHA-256 hash on Windows
certutil -hashfile release.tar.gz SHA256
Get-FileHash release.tar.gz -Algorithm SHA256certutil works in the Command Prompt and PowerShell; Get-FileHash is PowerShell's own command. Both print the hash in a different letter case from Linux tools, which does not matter: compare the hashes case-insensitively.
Compute a SHA-256 hash in Node.js and Python
import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
const hash = createHash("sha256");
for await (const chunk of createReadStream("release.tar.gz")) hash.update(chunk);
console.log(hash.digest("hex"));import hashlib
with open("release.tar.gz", "rb") as f:
print(hashlib.file_digest(f, "sha256").hexdigest())Both printed the same hash as shasum and sha256sum for the test file. Read the file in binary mode in Python; text mode can change line endings and therefore the hash.
What a matching hash proves
A matching hash proves the file is the one the hash describes: nothing was corrupted or swapped on the way. It does not prove who published it. If an attacker can change the download page, they can change the listed hash too. Where a project offers a signature, for example a .asc or .sig file, verify that as well, because it ties the file to the publisher's key.
Related tools
Generate strong, random passwords with a live strength estimate.
Generate cryptographically random v4 and time-ordered v7 UUIDs in bulk.
Encode text or files to Base64, with an optional URL-safe variant.
Decode a JWT to inspect its header, payload, and claims instantly.
Related guides
NIST's guidance dropped the rules most sign-up forms still enforce. Here is what it recommends instead, why length beats symbols in numbers, and how to generate passwords securely in code.
Every modern runtime can generate a UUID without a library. Here are the one-liners for JavaScript, Python and PostgreSQL, a tested UUID v7 function, and two common mistakes.
Base64 turns bytes into plain text so they can travel where only text is allowed. Here are the five places developers meet it most, with real examples, and the cases where it is the wrong tool.
Decoding a JWT shows its claims; verifying it proves they are genuine. Here are the checks a correct verification makes, written out in Node.js and Python so you can see each step.