Thursday, February 9, 2012

Testing Checksums

We all know that we should always test the checksum of the packages we download from Internet to avoid running malicious software, but we sometimes ignore it because it requires some manual process.

I am not aware of any tools/plugins that might be available for this purpose, but I made my own little shell script to help me with that. It didn't take me long, perhaps less than the time I needed to spend searching around.


if [ $# != 2 ]; then
echo "Usage: $0 file_name checksum"
exit 1

sum=`sha1sum $1 | awk '{print $1}'`
if [ "$sum" == "$2" ]; then
echo "Valid SHA-1 Checksum"
echo "*** Invalid SHA-1 Checksum ***"