Code, Computers & Random Junk

Verifying Checksums

chksum is a shellscript to manually verifying checksums in a simple way. Often when you download something there’s a MD5 or a SHA1 attached next to it… It’s easier to run it in a script than create one and then compare them manually.

The syntax is simple:

# chksum <md5 or sha*> <the checksum you copied on the site> <file>


$ chksum md5 d41d8cd98f00b204e9800998ecf8427e        ... OK

$ chksum md5 d41d8cd98f00b204e9800998ecf8427f        ... FAILED

chksum: WARNING: The checksum (d41d8cd98f00b204e9800998ecf8427f) did NOT match

The script is made to use/work with with both OS X and Linux/*BSD.

You can grab the script here:

md5 and shasum

Linux doesn’t have these, so I made a couple of “wrappers” for md5sum and the different shaNNNsum. Not that it’s needed that much, but I’m used to them and they’ll also serve as a layer if I need them for other scripts made for OS X. They doesn’t bring the full functionality, but at least som of the options.

See the ReadMe’s…

Using md5 -q will bring the MD5 checksum alone - great for scripting. And shasum… I find it easier to use one program than many different. Especially when moving between different platforms (using both OS X and Linux).

The usage is:

# shasum [-a <algo>] <file>
shasum -a 256 <file>

…instead of sha1sum, sha256sum, sha512sum etc. Without -a NNN it defaults to SHA1.

Read more at: “Moving between platforms”