Use Certutil to Get File Hash

I have been happily using the tiny Bullzip MD5 Calculator to quickly get an MD5 hash directly from the context menu in Windows Explorer.

But what if you need a hash on a where Bullzip isn’t installed? Or a different hash?

Enter certutil, a command-line tool built into Windows. Certutil has many functions, mostly related to viewing and managing certificates, but the -hashfile subcommand can be used on any file to get a hash in MD5, SHA256, or several other formats.

Here is the Help text for –hashfile. Note the available algorithms:

certutil1

Here’s an example of getting the MD5 hash of a file:

certutil -hashfile C:\bat\crashlog.txt MD5

certutil2

Note that the hash algorithms are case-sensitive. Be sure to type, for example, “MD5”, not “md5”.

Update September 20, 2018

Note that on Windows 7, the hash algorithms are case-sensitive. Be sure to type, for example, “MD5”, not “md5”. On Windows 8.1 and 10, case doesn’t matter. (Thanks, Charlie!)

Another nice thing I discovered is that after typing -hashfile, you can type the first one or two characters of the file name and press Tab to have it cycle through all file names that begin with those characters. Very handy e.g. when checking downloaded ISO files with file names like “en_windows_server_2012_r2_with_update_x64_dvd_6052708.iso”—all you have to type is “en” plus Tab.

4 thoughts on “Use Certutil to Get File Hash

  1. Charlie Arehart

    FWIW, I did lowercase md5 and it accepted it, on Windows 10 at least (and produced the same checksum as MD5). Thanks for sharing the post, otherwise.

  2. Mark Berry Post author

    Thanks, Charlie! You’re absolutely right, case sensitivity seems to be limited to Windows 7. I’ll update the post.

  3. RandomGuy

    Thanks for the tip. I am now using this in a script so it will run from the CLI. Just as an FYI, for getting it from the context menu, check out hashcheck. It adds a tab in the properties menu of the file and is great for a quick check. It only goes up to SHA-1 though.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.