Why Calculate an MD5 Checksum?
Free software is available all over the Internet. An unfortunate side effect, however is that you download something that has been surreptitiously replaced with malware, or other such malfeasance. Also, minor disruptions in data transfers have the ability, rare as it is, to cause a deformed packet, which still makes it past basic error checking mechanisms. So we want to validate files that we download to ensure they are reputable, and unchanged from the originals. Reputable websites that offer downloads will often display an MD5 checksum value (a string of characters and digits), typically placed near the download link. You will usually see the code preceded with "MD5: ", "md5sum: ", or similar. This code is calculated based upon the contents of the file that it represents, and if you perform an MD5 checksum of the file on your computer, it should match what is displayed on the website.Why Wouldn't You Calculate an MD5 Checksum?
There are a few reasons we don't do this. First, many sites don't provide an MD5 checksum value. There's not much we can do about that, other can contact the website owner and request one. Even when there is a checksum value displayed, it's cumbersome, and it takes time for larger files. You have to open a terminal shell locate the file, run the md5sum command... In a word, it's inconvenient. This is where cajamd5 comes in. This is a small shell script that you can add to the Caja file manager to make checking an MD5 quick and easy.
Creating the Script
First, we need to write our script. Open your favorite text editor, and type in the following:#!/bin/bash
for file in $CAJA_SCRIPT_SELECTED_FILE_PATHS
do
# Begin calculating the md5 sum of a file.
md5sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity \
--progress --title="MD5sum" --text="Calculating MD5 \
for:\n${file##*/}" --pulsate --auto-close
# This block exits the operation if the user clicks Cancel.
if [ "${PIPESTATUS[2]}" -ne "0" ]; then
rm /tmp/sum
exit 0
fi
# Calculation is finished, so display the result.
sum=$(cat /tmp/sum)
zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile : \
${file##*/}"
rm /tmp/sum
done
exit 0
Save the file in your home directory as with the name cajamd5.
Preparing the Script for the Menu
This is pretty simple, actually. All we need to do is make the script executable, then copy it into a directory Caja uses for scripts. To do this, Click the Menu, then Terminal.In the terminal, type in the following (just what's in bold):
you@computer ~ $ chmod +x cajamd5
you@computer ~ $ mv cajamd5 ~/.config/caja/scripts
you@computer ~ $ exit
That's it. You can now calculate an MD5 checksum on any file from within the graphical Caja file manager.
Below is a quick step-by-step of checking an MD5 sum. You'll want to click each image to get a better view.
![]() |
When you right-click on the file, the context menu appears, and you now have a Scripts option at the top, with our new script in it. Just left-click the cajamd5 item. |
![]() |
This automatically starts the md5 sum calculation against the file you selected. |
All done. We can now ensure the files we download are what the publisher intended, quickly and easily.
One small note: Caja will allow you to select multiple files, and calculate MD5 sums on all of them with one click of the cajamd5 script. This is done one file at a time. Normally it's not a big deal, but if the files are large (such as multiple .ISO images), this can take a while.
Credits:
- Ethan J. Eldridge provides a basic script on his blog to execute an action in Caja.
- Belham2 posted the code for calculating the MD5 sum, and displaying in a window on the Solus Project forums.
No comments:
Post a Comment