2007/12/01

Validate/verify MD5 or SHA1 hashes

Want to confirm that download hasn't been altered?

MD5:
if [ $(md5 -q pathHere) == 'md5-hash' ] ; then echo "OK"; else echo 'md5 hash mismatch!'; fi

SHA1:
if [ $(/usr/bin/openssl sha1 pathHere | awk '{print $NF}') == 'sha1-hash' ] ; then echo "OK"; else echo 'sha1 hash mismatch!'; fi


Substitute the path of the file to validate for "pathHere" above; similarly, the published hash for "md5-hash" or "sha1-hash".

Sure you could wrap it in a script, by why bother, when you have QuickSilver?

No comments: