Verify SHA-256 checksums on Windows, macOS and Linux

Calculate a file’s SHA-256 locally, compare the complete publisher checksum and understand what a matching result can prove.

3 min readTime needed: A few minutes; large files may take longer
In this guide

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

Find the correct reference value

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

PowerShell: calculate and compare

In the folder containing the download, replace the filename and reference placeholder:

Get-FileHash -LiteralPath '.\installer.exe' -Algorithm SHA256
$expected = 'PASTE_THE_PUBLISHERS_64_HEX_CHARACTERS'
$actual = (Get-FileHash -LiteralPath '.\installer.exe' -Algorithm SHA256).Hash
($expected -match '^[0-9a-fA-F]{64}$') -and ($actual -ieq $expected)

The final expression returns True only for a valid reference of that length matching the whole hash. These commands read the file; they do not execute it. Keep paths containing spaces quoted.

Command Prompt: certutil

Run this in CMD and compare its full hash line with the publisher’s value:

certutil -hashfile ".\installer.exe" SHA256

The success message means calculation succeeded, not that the reference matches. sha256sum is not a standard CMD command; it requires an additional environment such as WSL or suitable installed tools.

Browser option and mismatches

The checksum tool accepts files up to 20 MiB and reads the whole file into browser memory. Choose the same algorithm and paste the full expected checksum. Use a system tool for larger files.

For a mismatch, do not run the file. Check version, architecture, algorithm and download completeness, then download again from the official source. Contact the publisher if it persists. Never search for an arbitrary matching checksum to justify the file.

A small SHA-256 example you can reproduce

The three bytes 61 62 63 are the text abc in UTF-8 with no byte order mark and no line ending. Their SHA-256 is:

ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

This is one 64-character value. To test PowerShell without creating or overwriting a file, hash an in-memory stream:

$demoBytes = [byte[]](0x61, 0x62, 0x63)
$demoStream = [System.IO.MemoryStream]::new($demoBytes)
try {
  (Get-FileHash -InputStream $demoStream -Algorithm SHA256).Hash
} finally {
  $demoStream.Dispose()
}

Why a file containing “abc” might give another result

A text editor may add a newline or a byte order mark. Those are additional bytes, so the file is different. Compare the original downloaded file directly; opening and saving it can change what you are checking.

Does changing the filename change SHA-256?

Renaming a file without changing its contents leaves its checksum unchanged. An archive and the extracted file have different contents, so compare the checksum published for that exact object.

Microsoft reference: Get-FileHash, including InputStream

Command and reference check: . PowerShell and certutil were checked with the downloadable sample files. A matching checksum alone does not confirm that a file is safe.

How do I check a file’s SHA-256 in Windows PowerShell without installing anything?

The final expression returns True only for a valid reference of that length matching the whole hash. These commands read the file; they do not execute it. Keep paths containing spaces quoted.

sample.txt · 61 62 63
Get-FileHash -LiteralPath '.\sample.txt' -Algorithm SHA256
→ BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

File checksums

Microsoft PowerShell

How do I check a SHA-256 checksum in the macOS Terminal?

In a terminal, use shasum -a 256 on macOS or sha256sum on Linux when the command is available. Compare all 64 hexadecimal characters with the publisher’s reference for the exact file. Every byte matters, including a final line break; a successful calculation alone does not confirm a match.

sample.txt · 61 62 63
shasum -a 256 'sample.txt'
→ ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad  sample.txt

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

File checksums

Perldoc shasum

How do I verify a downloaded file with sha256sum on Linux?

In a terminal, use shasum -a 256 on macOS or sha256sum on Linux when the command is available. Compare all 64 hexadecimal characters with the publisher’s reference for the exact file. Every byte matters, including a final line break; a successful calculation alone does not confirm a match.

sample.txt · 61 62 63
sha256sum -- 'sample.txt'
→ ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad  sample.txt

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

File checksums

GNU Coreutils

What should I do if a downloaded file’s checksum does not match?

For a mismatch, do not run the file. Check version, architecture, algorithm and download completeness, then download again from the official source. Contact the publisher if it persists. Never search for an arbitrary matching checksum to justify the file.

61 62 63 → ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
61 62 63 64 → 88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589
≠

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

File checksums

How does a file checksum differ from a digital signature?

A checksum compares file bytes with a reference. A digital signature verifies signed data using a public key; attributing it to a publisher also requires a trusted key or certificate. Matching a hash or verifying a signature does not prove that software is harmless.

61 62 63 → SHA-256 → ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

Use the publisher’s official instructions for the exact version, operating system and architecture. A ZIP archive and the EXE extracted from it have different bytes. SHA-256 and SHA-512 are different algorithms; hexadecimal SHA-256 has 64 characters. Letter case does not change their value. Verify a publisher’s digital signature too when available.

A checksum describes file contents. A matching result establishes agreement with that checksum, not that the program is safe. If an attacker replaces both the file and the published value, this comparison cannot detect it.

File checksums

NIST FIPS 186-5

Decide whether to use the file after comparing SHA-256

Use the expected digest from the publisher’s trusted release page or signed manifest. Match the version, filename and platform. A checksum copied from the same untrusted mirror as the download does not establish the publisher’s identity.

Compare all 64 hexadecimal digits. If any differ, stop and obtain a fresh copy from the official source. For a training example, hash the three bytes abc without a trailing newline and compare with the worked example below.