Applescript droplet to get the SHA1 checksum

Jun 11, '10 07:30:00AM

Contributed by: RexRay

Many software downloads will supply an 'SHA1 Checksum' to verify that what you downloaded is what the developer intended and not some malware pretender. It may not be obvious how to check this without using Terminal.

I created an Applescript droplet for verifying the 'NSA Secure Hash Algorithm 1' checksum that is sometimes supplied to authenticate a download. It's pretty simple, calling a shell script to output the checksum hash.

Just paste the following into AppleScript Editor and save the script as an Application.

-- if applet is double-clicked
set chosenFile to choose file with prompt "Select the file to checksum:"
do shell script "/usr/bin/openssl sha1 " & quoted form of POSIX path of chosenFile
display dialog result buttons {"OK"} default button "OK"

-- or if the file is drag and dropped
on open chosenFile
  do shell script "/usr/bin/openssl sha1" & quoted form of POSIX path of chosenFile
  display dialog result buttons {"OK"} default button "OK"
end open

You can either drag the file to verify onto the droplet, or you can double-click the applet and navigate to the file in question. Either approach should yield a dialog with the file's path and its resulting checksum hash.

The code was assembled from multiple sources, including Apple's Developer site, and tested by me under Snow Leopard.

[crarko adds: I tested this, and it works as described. This earlier hint describes a command-line tool (md5deep) that can be used to calculate a variety of checksums.]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2010060915020592