I was sent a script to run by an analyst who advised to verify the MD5 hash. This is good advice to ensure that I receive the correct content. And happens to be the advise I gave the DBA manager before restoring backup files that was going to take hours to download.
The idea is creating an MD5 hash from the file contents is a fingerprint that tells me whether the file is the same or different quickly and easily. The analyst tells me the hash of the file on the source. I generate a hash on the destination and compare. If they differ, then we have a problem.
I do this all the time on Linux. However, the application I was working with is on Windows. And uploading the file to a Linux server from my workstation wouldn’t really tell me if the file on the Windows server has the correct hash as corruption (ever so unlikely) could have happened over one upload but not the other.
So, I was curious if there was a way to do this on Windows. Turns out there is.
certutil -hashfile C:\scripts\filename.sql MD5
The certutil.exe command is a program installed as part of Certificate Services used typically to view SSL information. (I used it via Powershell, but I bet it works via CMD too.) The various flags available makes it look like something extremely useful to know exists. And, I am surprised at never having seen it prior to today.