Quick Bits - Verify the Hash of a Download
May 21, 2010
Just whipped up a script to check the SHA1 & MD5 hashes of a file and compare it to the clipboard. I rolled it into an Automator workflow so it can be attached as a folder action.
Basically, the script takes a parameter, which is the full file name, runs openssl sha1 and openssl dgst on it, and compares each value to what’s in the clipboard. If either signature match the clipboard, it pops up a growl notification confirming that the signature matches. If it doesn’t get a match, it growls the Sha1 and MD5 tags.
Get it here: hashworkflow.zip
You’ll need Growl, if you don’t have it, and you’ll need to install growlnotify, which comes with Growl.
Instructions:
- Unzip.
- Open the .workflow
- Go to File -> Save As: (may not be necessary…)
- Ctrl+click on your Downloads folder and select Services -> Folder Actions Setup…
- Select “Hash Downloads.workflow”
Issues:
The script uses pbpaste to read the clipboard. Since there’s no way to guarantee pbpaste is giving back text, this may cause a problem when there’s large amounts of data on the clipboard. Clipboard contents are assigned to a variable using the syntax PB=pbpaste, so there shouldn’t be a risk of accidentally running a command that isn’t intended, but I haven’t extensively tested for this.
Disclaimer
I’ve tested this for approx. 6 minutes. I make no claims about the safety of this software, and take no responsibility for the results of running it. I took shortcuts and the code sucks. Caveat Downloador.
Eric Danielson is a professional systems engineer and an amateur economist living in San Francisco.
He’s primarily focused on the growth of ubiquitous computing and its impact on society, human evolution and cognitive science as applied to economies and politics,
and the impact of open source and the ‘hacker’ movement on power dynamics and human progress, though this blog will cover other issues of interest.
He can frequently be found at one of the many fine coffee shops or bars in the city, and may also be spotted at meetups, barcamps, or random street fairs. Find Eric on: Twitter - Github - LinkedIn