Tuesday, 10 February 2015

Check downloads using SHA-1 and MD5

When you download a large file, such as a distribution of Linux for the Raspberry Pi, you are provided with a checksum to check the download is all correct. Has anyone ever checked their download? Would you know how to? I have to admit I rarely check. However if things did go wrong it would be very easy to overlook the fact the download went wrong. As you will see in this blog it is also possible to use this tool to check that SD cards have been written to correctly.

There are two types of checksum which are commonly used SHA-1 and MD5. I will explain how to use both of these.

First lets look how to do this on an Apple Mac.

To determine the MD5 open the terminal and type either

openssl md5 filename

or for SHA-1

openssl sha1 filename

for the MD5 you don't need to type openssl.

On a Linux system type the following into a terminal.

md5sum filename

and for SHA-1 you need to type

sha1sum filename

depending which checksum you are wanting to use.

Don't forget, if your filename is in a different folder, you will have to include the location along with the filename as below


Did you know that you are able to check that the image has burned correctly onto say an SD Card by checking the card once you have burned it?

For example on an Apple Mac to check a disk type the following

sudo openssl sha1 /dev/rdisk2

where /dev/rdisk2 is the path to the disk you want to check. Note you will probably need to use the sudo command to ensure you have the correct permissions. This is handy if you want to check that all your disks have burned correctly.