File Hash Checker: How to Check the Hash of a File

"Hash checker" means two different jobs. One is working out the hash (checksum) of a file you have and comparing it with the value the publisher lists, to prove the download is complete and unaltered. The other is checking a hash against a database of known malware. This guide covers both, with the exact commands for Windows, macOS and Linux and a no-install option in the browser.

What a file hash is

A hash is a short fingerprint calculated from every byte of a file. The same file always gives the same hash; change a single byte and the hash is completely different. The file name, date and location play no part, so a renamed copy has the same hash as the original. You can recognise the algorithm by the length of the value:

AlgorithmLengthUse it for
MD532 hex charactersLooking up known files and malware samples. Not safe for proving a file is untampered.
SHA-140 hex charactersLooking up known files. Also no longer collision-resistant.
SHA-25664 hex charactersVerifying downloads. The one to use when the publisher offers a choice.

Check a file's hash on Windows

Nothing needs to be installed. Open PowerShell in the folder that holds the file (Shift + right-click the folder, then Open PowerShell window here or Open in Terminal) and run:

Get-FileHash .\setup.exe

Get-FileHash returns SHA-256 unless you ask for something else:

Get-FileHash .\setup.exe -Algorithm MD5
Get-FileHash .\setup.exe -Algorithm SHA1

To hash several files at once and keep the output readable:

Get-FileHash *.exe -Algorithm SHA256 | Select-Object Hash, Path

In the classic Command Prompt, certutil does the same job:

certutil -hashfile setup.exe SHA256

Check a file's hash on macOS and Linux

On a Mac, open Terminal and run:

shasum -a 256 file.dmg
shasum file.dmg        # SHA-1
md5 file.dmg

On Linux:

sha256sum file.iso
sha1sum file.iso
md5sum file.iso

Tip: type the command and a space, then drag the file into the terminal window to paste its full path.

Check a hash in your browser, without commands

Drop a file onto the iMalware scanner. It calculates the file's MD5 inside your browser, shows it next to the file name with a copy button, and checks it against the malware database in the same step. The file is not uploaded and there is no size limit. The scanner shows MD5 only; for a SHA-256 value use one of the commands above.

Compare the hash with the publisher's checksum

Many download pages list a SHA-256 value, or offer a SHA256SUMS or .sha256 file. The whole value has to match, not just the first and last few characters. Upper and lower case do not matter.

Let the computer compare for you. In PowerShell:

(Get-FileHash .\file.iso).Hash -eq "PASTE-THE-PUBLISHED-HASH-HERE"

It prints True or False. On Linux, with the checksum file in the same folder as the download:

sha256sum -c SHA256SUMS --ignore-missing

If the values differ, the download is corrupt, incomplete or not the file the publisher released. Delete it and download it again from the official site.

Know what a match proves. It shows your copy is identical to the file the checksum was made from. If an attacker replaced both the download and the checksum on the same page, they will still match. A valid digital signature from the publisher (see checking the digital signature) is stronger evidence of who made the file.

Check a hash against known malware

Paste an MD5, SHA-1 or SHA-256 value into the malware hash lookup, one hash or a list of up to 500. A match means that exact file is a known malware sample. "Not found" only means the hash is not in the database: new, rare or modified malware has a hash nobody has recorded yet, so treat it as "unknown", not "safe". The result's VirusTotal button shows what antivirus engines say about the same hash, still without uploading the file.

What a hash does not tell you

  • It cannot be turned back into the file. A hash holds no file name, no content and nothing about what the program does. All you can do with one is look it up somewhere that has seen the same file before.
  • It does not survive changes. Re-saving, re-compressing or patching a file gives a new hash, which is why malware authors repack their files and why a hash lookup cannot catch new variants.
  • The hash of an archive is not the hash of its contents. A ZIP and the program inside it have different hashes. See scanning ZIP files.

Frequently Asked Questions

How do I check the hash of a file without installing anything?

On Windows run Get-FileHash followed by the file name in PowerShell, or certutil -hashfile with the file name and SHA256 in Command Prompt. On macOS use shasum -a 256, on Linux sha256sum. For an MD5 without any commands, drop the file on the iMalware scanner, which calculates it in your browser.

Which hash should I use: MD5, SHA-1 or SHA-256?

Use SHA-256 to verify a download whenever the publisher provides it. MD5 and SHA-1 are still widely used to identify known files, including malware samples, but both have known collision weaknesses, so they should not be relied on to prove a file has not been tampered with.

Does a matching hash mean the file is safe?

It means your copy is identical to the file the checksum was published for. Whether that file is trustworthy depends on the publisher and on where the checksum came from. A checksum hosted next to the download protects against corruption, but not against a compromised website.

What can someone learn from a file's hash?

Only whether the same file has been seen before. A hash cannot be reversed into the file, and it contains no name or content. Looking it up in a malware database or on VirusTotal shows whether that exact file is already known.