windows 系统自带了文件校验工具——certutil,但这个工具是命令行下的。
certutil -hashfile <文件名> <哈希类型>
比如:
certutil -hashfile test.txt sha1
但如果每次都要打开 powershell 输入的话会很麻烦,所以,在网上找了右键添加校验的代码:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\hash] "MUIVerb"="校验文件 Hash" "SubCommands"="" "Icon"="PowerShell.exe" ; SHA1 [HKEY_CLASSES_ROOT\*\shell\hash\shell\01menu] "MUIVerb"="SHA1" [HKEY_CLASSES_ROOT\*\shell\hash\shell\01menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm SHA1 | format-list" ; SHA256 [HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu] "MUIVerb"="SHA256" [HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm SHA256 | format-list" ; SHA384 [HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu] "MUIVerb"="SHA384" [HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm SHA384 | format-list" ; SHA512 [HKEY_CLASSES_ROOT\*\shell\hash\shell\04menu] "MUIVerb"="SHA512" [HKEY_CLASSES_ROOT\*\shell\hash\shell\04menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm SHA512 | format-list" ; MACTripleDES [HKEY_CLASSES_ROOT\*\shell\hash\shell\05menu] "MUIVerb"="MACTripleDES" [HKEY_CLASSES_ROOT\*\shell\hash\shell\05menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm MACTripleDES | format-list" ; MD5 [HKEY_CLASSES_ROOT\*\shell\hash\shell\06menu] "MUIVerb"="MD5" [HKEY_CLASSES_ROOT\*\shell\hash\shell\06menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm MD5 | format-list" ; RIPEMD160 [HKEY_CLASSES_ROOT\*\shell\hash\shell\07menu] "MUIVerb"="RIPEMD160" [HKEY_CLASSES_ROOT\*\shell\hash\shell\07menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm RIPEMD160 | format-list" ; Allget-filehash -literalpath '%1' -algorithm RIPEMD160 | format-list [HKEY_CLASSES_ROOT\*\shell\hash\shell\08menu] "CommandFlags"=dword:00000020 "MUIVerb"="校验全部" [HKEY_CLASSES_ROOT\*\shell\hash\shell\08menu\command] @="powershell -noexit get-filehash -literalpath '%1' -algorithm SHA1 | format-list;get-filehash -literalpath '%1' -algorithm SHA256 | format-list;get-filehash -literalpath '%1' -algorithm SHA384 | format-list;get-filehash -literalpath '%1' -algorithm SHA512 | format-list;get-filehash -literalpath '%1' -algorithm MACTripleDES | format-list;get-filehash -literalpath '%1' -algorithm MD5 | format-list;get-filehash -literalpath '%1' -algorithm RIPEMD160 | format-list"
将上面的代码复制到一个空的 reg 文件里,保存编码为 UTF16-LE,然后双击执行就可以了。windows11 可能需要到二级菜单里找。
卸载命令的代码如下:
Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\*\shell\hash]