Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate MD5 and SHA-1
set message to ""
tell application "Finder"
try
set selected_items to selection
on error
error "No selected Finder items"
end try
repeat with selected_item in selected_items
set file_name to POSIX path of (selected_item as alias)
if text -1 of file_name is not equal to "/" then
set sha1 to do shell script "/usr/bin/openssl sha1 " & quoted form of file_name
set md5 to do shell script "/usr/bin/openssl md5 " & quoted form of file_name
set message to message & file_name & return & "MD5: " & (word -1 of md5) & return & (word -1 of sha1) & return & return
end if
end repeat
end tell
if length of message is 0 then
error "You can't calculate the checksum of a folder"
else
try
display dialog text 1 thru -3 of message with title "MD5 and SHA-1" buttons {"OK"} default button "OK" cancel button "OK"
end try
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.