807

Is there a built-in checksum/hash utility on Windows 7?

chicks
  • 590
user64996
  • 8,427
  • 5
  • 21
  • 16

31 Answers31

1376

CertUtil is a pre-installed Windows utility that can be used to generate hash checksums:

certUtil -hashfile pathToFileToCheck [HashAlgorithm]

HashAlgorithm choices: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

So for example, the following generates an MD5 checksum for the file C:\TEMP\MyDataFile.img:

CertUtil -hashfile C:\TEMP\MyDataFile.img MD5

To get output similar to *Nix systems you can add some PowerShell magic:

$(CertUtil -hashfile C:\TEMP\MyDataFile.img MD5)[1] -replace " ",""
tedr2
  • 13,761
234

There is a built in utility, as specified in this other answer.

You may, however, wish to use this freeware app called HashTab that integrates neatly with Windows Explorer by registering a... well, a tab in the properties dialog of files. It's pretty sweet.

HashTab screenshot

201

I'm using HashCheck (latest version) which integrates itself as a property page for files and includes a context menu to compare against hash check files (SFV).

It is free, and the source is available.

Screenshot

Andrew Moore
  • 4,955
97

PowerShell version 4 and up includes the Get-FileHash cmdlet.

powershell get-filehash -algorithm md5 <file_to_check>

Use doskey to make a persistent alias that's easier to remember.

doskey sha1sum=powershell get-filehash -algorithm sha1 "$1"
doskey md5sum=powershell get-filehash -algorithm md5 "$1"
87

There is the FCIV utility from Microsoft, the Microsoft File Checksum Integrity Verifier (download link).

The Microsoft File Checksum Integrity Verifier tool is an unsupported command line utility that computes MD5 or SHA1 cryptographic hashes for files.

It doesn't show Windows 7 in system requirements but I've just used it in Windows 8 and it worked.

User5910
  • 566
  • 1
  • 4
  • 21
creator
  • 1,011
51

The new version of 7-Zip also gives you the option of checksums just by right clicking (this doesn't include MD5). It has SHA-1, SHA-256, CRC-32, CRC-64, etc.

Enter image description here.


For MD5 you can download HashTab and check by right clicking and then properties.

Enter image description here

abe312
  • 637
24

Here's one I've used before that integrates nicely with Explorer's "Properties" dialog: Summer Properties. It's open source, and an x64 version is also available.

SummerProperties screen shot

I also like Safer Networking's FileAlyzer, which provides additional features as well. But just for checksums, Summer Properties is lightweight and does the job.

Gareth
  • 19,080
Chris W. Rea
  • 10,978
18

I am adding this here only because I didn't see any fully working powershell examples, ready for copy-paste:

C:\> powershell "Get-FileHash %systemroot%\system32\csrss.exe"

Algorithm       Hash
---------       ----
SHA256          CB41E9D0E8107AA9337DBD1C56F22461131AD0952A2472B4477E2649D16E...

C:\> powershell -c "(Get-FileHash -a MD5 '%systemroot%\system32\csrss.exe').Hash"

B2D3F07F5E8A13AF988A8B3C0A800880

C:\> CertUtil -hashfile "%systemroot%\system32\csrss.exe" MD5 | findstr -v file
b2 d3 f0 7f 5e 8a 13 af 98 8a 8b 3c 0a 80 08 80

C:\>

2019 Update:

The certutil output seems to have changed since Windows 8, so my old filter to isolate the hash doesn't work anymore. The extraneous spaces are gone too - one less thing to worry about when scripting. Here is the new copy-paste-able demo:

C:\>CertUtil -hashfile "%systemroot%\system32\csrss.exe" | findstr -v ash
0300c7833bfba831b67f9291097655cb162263fd

C:\>CertUtil -hashfile  "%systemroot%\system32\csrss.exe" SHA256 | findstr -v :
a37d616f86ae31c189a05b695571732073b9df97bf5a5c7a8ba73977ead3e65b

C:\>ver

Microsoft Windows [Version 10.0.16299.1451]

C:\>

To make this more resilient against breakage from yet another future change in certutil, we should look for lines with non-hex characters to filter out: [^0-9a-zA-Z]. That should also make it safer for other locales and languages.

C:\>CertUtil -hashfile  "C:\windows\fonts\arial.ttf" | findstr -vrc:"[^0123-9aAb-Cd-EfF ]"
12c542ef8c99cf3895ad069d31843a5210857fdc

Why is that actual anti-hex regex so weird ? See this question to learn how regex ranges in findstr don't work as they should. I included an extra space character for backward-compatibility with older certutil versions, but it is optional.

Note that the powershell Get-FileHash default is SHA256, while certutil still defaults to SHA1. So specify your algorithm explicitly where needed. You can quickly check the available options like this:

C:\>powershell -c "Get-FileHash -?" | findstr gori

    Get-FileHash [-Path] <string[]> [-Algorithm {SHA1 | SHA256 | SHA384 | SHA512 | MACTripleDES | MD5 | RIPEMD160}]
    Get-FileHash -LiteralPath <string[]> [-Algorithm {SHA1 | SHA256 | SHA384 | SHA512 | MACTripleDES | MD5 |
    Get-FileHash -InputStream <Stream> [-Algorithm {SHA1 | SHA256 | SHA384 | SHA512 | MACTripleDES | MD5 | RIPEMD160}]

C:\>certutil -hashfile -v /? | findstr gori

  CertUtil [Options] -hashfile InFile [HashAlgorithm]
Hash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512
16

Nirsoft's HashMyFiles is small utility that allows you to calculate the MD5 and SHA1 hashes of one or more files in your system. You can easily copy the MD5/SHA1 hashes list into the clipboard, or save them into text/html/xml file.

HashMyFiles can also be launched from the context menu of Windows Explorer, and display the MD5/SHA1 hashes of the selected file or folder.

alt text

HashMyFiles is freeware and portable.

Gareth
  • 19,080
14

I found this PowerShell script:

param([switch]$csv, [switch]$recurse)

[Reflection.Assembly]::LoadWithPartialName("System.Security") | out-null
$sha1 = new-Object System.Security.Cryptography.SHA1Managed
$pathLength = (get-location).Path.Length + 1

$args | %{
    if ($recurse) {
        $files = get-childitem -recurse -include $_
    }
    else {
        $files = get-childitem -include $_
    }

    if ($files.Count -gt 0) {
        $files | %{
            $filename = $_.FullName
            $filenameDisplay = $filename.Substring($pathLength)

            if ($csv) {
                write-host -NoNewLine ($filenameDisplay + ",")
            } else {
                write-host $filenameDisplay
            }

            $file = [System.IO.File]::Open($filename, "open", "read")
            $sha1.ComputeHash($file) | %{
                write-host -NoNewLine $_.ToString("x2")
            }
            $file.Dispose()

            write-host
            if ($csv -eq $false) {
                write-host
            }
        }
    }
}

Source: Calculating SHA1 in PowerShell

It leverages .NET which I assume you have installed

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
bquaresma
  • 526
8

A batch file based on pbarney's comment to the answer with the most upvotes: This copies the MD5 hash of whatever file is dragged onto the batch file to the clipboard:

@ECHO OFF
FOR /f "tokens=*" %%i IN ('@certutil -hashfile %1 MD5 ^| find /v "hash of file" ^| find /v "CertUtil"') DO SET r=%%i
SET r=%r: =%
ECHO %r% | clip

To make it a context menu item instead:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Get MD5]
@="Copy MD5 to Clipboard"

[HKEY_CLASSES_ROOT\*\shell\Get MD5\command]
@="\"C:\\<PATH TO BAT FILE>\\getMD5.bat\" \"%1\""
8

Microsoft File Checksum Integrity Verifier. It can compute MD5 and SHA-1 hash values.

Download, extract the files, then open a command prompt, go to the extracted path and then type the following command:

fciv -md5 filepath\filename.extension

For example:

fciv -md5 d:\programs\setup.exe
David
  • 105
7

Unfortunately, not that I'm aware of, but Microsoft's Sysinternals suite includes a nice tool called sigcheck.

eug
  • 974
4

This is just a cmd shell script which uses tedr2's answer but strips off the extraneous output lines and spaces:

:: hash.cmd : Get a hash of a file
:: p1: file to be hashed
:: p2: Hash algorithm in UPPERCASE
:: p3: Output file

@setlocal
@for /f "tokens=*" %%a in (
'@certutil -hashfile %1 %2 ^|find /v "hash of file" ^|find /v "CertUtil"'
) do @(
  @set str=%%a
)
@set str=%str: =%
@echo %str%
@endlocal

The output can be re-directed to a file if required:

@echo %str% > %3

e.g.

sys> \dev\cmd\hash.cmd MyApp.dll SHA1
8ae6ac1e90ccee52cee5c8bf5c2445d6a92c0d4f
Jool
  • 256
4

Cygwin contains an md5sum.exe utility that should do what you want.

4

QuickHash supports SHA-256 and SHA-512. I needed SHA-256 support to verify the checksum of whitelisted JavaScript libraries for inclusion in a Firefox addon.

4

MD5 Context Menu does exactly this. It adds an MD5 option to the context menu of files:

Enter image description here

Alt text

MD5 Context Menu is a freeware shell extension for Windows which displays the MD5 hash sum of the selected file.

It says it's compatible with Windows 95, 98, ME, NT, 2000, and XP, although it works for me perfectly fine on Windows 7. It's a tiny download (238 KB) and includes everything you need.

2

1. checksum

I use checksum command-line utility.

Usage:

checksum [-t=sha1|sha256|sha512|md5] [-c=signature] [-f=]filepath


2. Command-line arguments

  • -?, --help, -h
    Prints out the options.
  • -f, --file=VALUE
    Filename.
  • -t, --type, --hashtype=VALUE
    Hashtype Defaults to md5.
  • -c, --check=VALUE
    Optional: check - the signature you want to check. Not case sensitive.

3. Examples of usage

# Check md5 for "E:\Саша Неотразима\Sasha-Irresistible.exe" file
SashaChernykh@DESKTOP-0G54NVG E:\Саша Неотразима
$ checksum -f "E:\Саша Неотразима\Sasha-Irresistible.exe"
342B45537C9F472B93A4A0C5997A6F52
# Check sha256
SashaChernykh@DESKTOP-0G54NVG E:\Саша Неотразима
$ checksum -f "E:\Саша Неотразима\Sasha-Irresistible.exe" -t=sha256
F6286F50925C6CBF6CBDC7B9582BFF833D0808C04283DE98062404A359E2ECC4
# Correct 41474147414741474147 sha256 hash or not?
SashaChernykh@DESKTOP-0G54NVG E:\Саша Неотразима
$ checksum -f "E:\Саша Неотразима\Sasha-Irresistible.exe" -t=sha256 -c 41474147414741474147
Error - hashes do not match. Actual value was 'F6286F50925C6CBF6CBDC7B9582BFF833D0808C04283DE98062404A359E2ECC4'
# One more attempt
SashaChernykh@DESKTOP-0G54NVG E:\Саша Неотразима
$ checksum -f "E:\Саша Неотразима\Sasha-Irresistible.exe" -t=sha256 -c F6286F50925C6CBF6CBDC7B9582BFF833D0808C04283DE98062404A359E2ECC4
Hashes match..
2

The correct answer is of course, yes, CertUtil (see tedr2's answer).

But I'll add Penteract's free File Checksum Verifier which, I think, is one of the most user-friendly programs. (Disclaimer: I'm affiliated with Penteract.)

Some of its advantages:

  • Compares the calculated and expected hashes for you.
  • Minimalistic - no item in files' context-menus, no extra tab on files' properties.

To verify this program's integrity (against man-in-the-middle attacks) - it downloads over a secure connection.

Penteract File Checksum Verifier

Plus: free, offline (so you don't have to upload your files), user-friendly (drag a file in and get the result), launches from the start menu (no need to look for the downloaded executable when you want to use it a year from now), and supports MD5, SHA1, SHA256, etc.

User42
  • 220
1

This is not a built-in utility, but its a very good option

https://checksumcompare.sanktuaire.com

You could compare checksum by file and/or summaries if two folders differ or are identical.

1

You can try msys2, it is here.

Just type (algorithm)sum. (algorithm) is the hash algorithm you want to use e.g. md5, sha1, sha256.

Unlike Cygwin, this tool is portable, you just to download the .zip file and extract in anywhere you want. You can use it by a simple click (msys2.exe).

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400
pah8J
  • 755
  • 1
  • 6
  • 14
1

OpenHashTab is open source, integrates with Explorer, and is actively developed.

It's a good alternative to HashCheck, as that one isn't maintained any more (for over 6 years).

OpenHashTab 3.0 file properties tab

Settings

Qtax
  • 468
1

You can use MD5sums for Windows, a download of only 28 KB (Cygwin might be overkill if all you want to do is compute MD5 hashes).

The easiest way to use it is to use Explorer to drag and drop files on md5sums.exe to obtain their MD5 hashes.

Josh
  • 443
1

Something like this: winmd5sum.
This one's also nice: sendtoMD5 - right click, send to ..., and it gets you the result.

Rook
  • 24,289
1

HashTab 3.0 is a free shell extension that calculates many checksums, including MD5. It's integrated as a new tab in the File Properties.

studiohack
  • 13,477
Snark
  • 33,097
0

If you don't have time to check output from certutil character by character <hash size> number of times, pipe to find utility to see if checksum matches:

certutil -hashfile ekaf_elbatuc.exe sha256 | find "<checksum>" && echo File ok. || echo Some mole or rat waz hia

But then what's the point of getting hash from same server as the file itself?

Tested on Win 10 CMD

Zimba
  • 1,291
0

This is how I calculate checksums from Explorer using no third-party software.

On Windows 10 (and probably previous versions) follow these steps:

Using explorer, open the "Send To" folder by typing this into the address bar

shell:sendto

Create a batch file in this folder called something like Calculate SHA1 and MD5.cmd

and add this text

@echo off
certUtil -hashfile %1 SHA1
certUtil -hashfile %1 MD5
pause

You will now be able to calculate SHA1 and MD5 checksums for any file from Explorer, just by right-clicking a file and choosing send to Calculate SHA1 and MD5.cmd

Off course, you can change the name of the above file and choose to add other checksums, or even create multiple files each with a different type of hash.

I have another batch file called Calculate SHA256.cmd, which I prefer to use independently (you wouldn't want to calculate every type of hash from one batch file as this would take too long for very big files).

enter image description here

Some more notes

Just to make the output a little less cluttered, I prefer to pipe the output through findstr.

certUtil -hashfile %1 SHA256 | findstr ^1

The pause instruction at the end of the batch file is essential, otherwise the window will disappear immediately.

DAB
  • 131
0

Well, I have made a program to calculate some hashes from a file. I hope it helps you.

What does this do? It calculates the SHA-1 hash, SHA-384 hash, MD5 hash and SHA-256 hash. Well, that's about it :)

-1

There are like 100 third-party tools out there. I use MD5Hash. For downloads with sfv files, just use TeraCopy to verify the hashes.

surfasb
  • 22,896
-2

For a solution that works on Windows or just about any other environment, use Python.

  1. install Python -- a Windows installer is provided on https://www.python.org/downloads/

  2. download a tested cksum implementation, e.g. http://pastebin.com/raw.php?i=cKATyGLb -- save the contents of this to say, c:\cksum.py or wherever you find convenient

Then to perform a checksum:

python c:\cksum.py INPUTFILE

Not as fast as a compiled utility, but compatible with Unix cksum and runs anywhere.

Christian
  • 7,217
  • 1
  • 27
  • 39
-3

I like digestIT, although it seems to be fairly old and maybe not maintained.