Menu

A simple method to hash file under Windows NT6

2019-03-07 - Live on and Go

Since Windows NT6, Windows started to include certification utility. This file is called “certutil.exe”. You may call it through Windows command line.

File hashing is significantly important in file checking to make sure it is not corrupted. To perform file hashing, you will need to execute following command line:

certutil -hashfile [Target File Path] [Algorithm]

For example, if you want to hash a file in “D:\test.txt” with MD5 algorithm, you are supposed to execute command line:

certutil -hashfile "D:\test.exe" MD5

In order to integrate this function to right-click button, you should write batch program and edit registry.

For batch program, you should write the following code:

@echo off

title Hash File with SHA-1 Algorithm
echo Hash File with SHA-1 Algorithm
echo Powered by zero.tangptr@gmail.com

echo ============Start Hashing============
certutil -hashfile %1 SHA1
echo ============Hash Complete============

pause

Save the code to C:\Windows\hashsha1.bat

Next, we should edit the registry. To simplify your work and make your editing safer, we are going to create a registry file.
Create a “*.reg” file, and put the following code:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\GetSHA1]
@="Hash File with SHA-1 Algorithm"

[HKEY_CLASSES_ROOT\*\shell\GetMD5\command]
@="\"C:\\Windows\\hashsha1.bat\" \"%1\""

Execute the registry editor file. Then the right-click button would start to work.
For an example, we download Notepad++ from internet. We selected to download Notepad v7.6.4 x64 installer. From official Notepad++ website, the expected SHA-1 hash result is:
4a6636b83a61fdf20e811bcaf6e19454b3af78a8
You may check this from website link:
https://notepad-plus-plus.org/repository/7.x/7.6.4/npp.7.6.4.sha1.md5.digest.txt

We click on the right-click button. A command line windows pops up:

SHA-1 hash result

You may notice that the most complex algorithm that certutil supports is the SHA-512 algorithm.

Leave a Reply

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