Add the calculation of SHA-1 and MD5 hashes to the file context menu
Good day!
How often do you check downloaded files for hash equality? I never. But today, for some reason, I decided to break with this vicious practice and make my life more secure.
Agree, the main reason not to compare the hash of the file is laziness. You need to look for some program, run it, set it on a file, and this is just a lot of action. How can this procedure be simplified? I didn’t come up with anything better than adding the “Calculate Hash” option to the file’s context menu. For those interested, I offer a brief instruction.
We take from here File Checksum Integrity Verifier utility - a console utility for calculating and comparing Microsoft's MD5 and SHA-1 hashes. There you can read what kind of animal it is and what it is eaten with. The downloaded Windows-KB841290-x86-ENU.exe file can be opened as a zip archive and see that it contains two files: fciv.exe itself and ReadMe.txt, which contains help for the utility. We are not interested in the ReadMe file, and fciv.exe must be placed in one of the directories specified in the PATH variable in order to call it from the command line without specifying the full path. I put in system32. You can verify that the utility works by setting it from the command line on any file:
To expand the context menu of the files, you will need to slightly podshamanit in the registry.
Run regedit.exe, go to HKEY_CLASSES_ROOT \ * - this is the section responsible for the context menu of all file types. In the shell section, create a subsection with any name (I have it fciv_md5). In the default parameter, we write the desired name of the menu item (for example, Compute MD5). In the created subsection (fciv_md5), we create another subsection with the name command, and we write a magic line in the default parameter:
The line tells cmd.exe to run with the command
To add an item to calculate SHA-1, we perform the same sequence of actions, changing only the names. The command in this case looks like this: You
should get something like this:
All of the above in one file:
One:
Two:
All good and matching hashes!
UPD As navion suggests in the first comment, you can do without installing FCIV and use the built-in CertUtil utility. In this case, item 1 becomes irrelevant, and the command in regedit changes to:
for MD5:
for SHA1:
and, in addition, it becomes possible to calculate the SHA256 hash:
How often do you check downloaded files for hash equality? I never. But today, for some reason, I decided to break with this vicious practice and make my life more secure.
Agree, the main reason not to compare the hash of the file is laziness. You need to look for some program, run it, set it on a file, and this is just a lot of action. How can this procedure be simplified? I didn’t come up with anything better than adding the “Calculate Hash” option to the file’s context menu. For those interested, I offer a brief instruction.
1. Installing the program
We take from here File Checksum Integrity Verifier utility - a console utility for calculating and comparing Microsoft's MD5 and SHA-1 hashes. There you can read what kind of animal it is and what it is eaten with. The downloaded Windows-KB841290-x86-ENU.exe file can be opened as a zip archive and see that it contains two files: fciv.exe itself and ReadMe.txt, which contains help for the utility. We are not interested in the ReadMe file, and fciv.exe must be placed in one of the directories specified in the PATH variable in order to call it from the command line without specifying the full path. I put in system32. You can verify that the utility works by setting it from the command line on any file:
fciv -md5 C:\test.dat
- to calculate MD5 fciv -sha1 C:\test.dat
- to calculate SHA-12. Creating a context menu item
To expand the context menu of the files, you will need to slightly podshamanit in the registry.
Run regedit.exe, go to HKEY_CLASSES_ROOT \ * - this is the section responsible for the context menu of all file types. In the shell section, create a subsection with any name (I have it fciv_md5). In the default parameter, we write the desired name of the menu item (for example, Compute MD5). In the created subsection (fciv_md5), we create another subsection with the name command, and we write a magic line in the default parameter:
cmd.exe /k fciv -md5 "%1"
The line tells cmd.exe to run with the command
fciv -md5 "%1"
and display the result. To add an item to calculate SHA-1, we perform the same sequence of actions, changing only the names. The command in this case looks like this: You
cmd.exe /k fciv -sha1 "%1"
should get something like this:
All of the above in one file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\fciv_md5]
@="Compute MD5"
[HKEY_CLASSES_ROOT\*\shell\fciv_md5\command]
@="cmd.exe /k fciv -md5 \"%1\""
[HKEY_CLASSES_ROOT\*\shell\fciv_sha]
@="Compute SHA"
[HKEY_CLASSES_ROOT\*\shell\fciv_sha\command]
@="cmd.exe /k fciv -sha1 \"%1\""
3. Calculate the SHA-1 hash with two clicks of the mouse:
One:
Two:
All good and matching hashes!
UPD As navion suggests in the first comment, you can do without installing FCIV and use the built-in CertUtil utility. In this case, item 1 becomes irrelevant, and the command in regedit changes to:
for MD5:
cmd.exe /k CertUtil -hashfile "%1" MD5
for SHA1:
cmd.exe /k CertUtil -hashfile "%1" SHA1,
and, in addition, it becomes possible to calculate the SHA256 hash:
cmd.exe /k CertUtil -hashfile "%1" SHA256