Lazy File Checksums
Calculating a file checksum is a routine activity I need to perform occasionally.
If you are a Powershell fan, and you have Powershell 4.0 or above, you can use the Get-FileHash cmdlet. I quite like Powershell but for some reason I can’t quite explain I instictively reach for cmd.exe for these kind of tasks.
It turns out that CertUtil.exe can hash files too, so I hacked together this:
@echo off
set x=.sha512
set hfn=%1%x%
@certutil -hashfile %1 SHA512 | sort /r | more +2 > %hfn%
To use:
- Save it to a file called
hash-file.cmd
somewhere on your path. - Type
hash-file <your-file-here.file>
at a command prompt. - A handy
<your-file-here.file.sha512>
will be created alongside the original.
Leave a Comment
Your email address will not be published. Required fields are marked *