Monday, October 27, 2008

Right click on a file to calculate hash

HashTab v1.14 is my favorite Windows Shell Extension for calculating and comparing hash values. It works with MD5 and SHA-1 hashes by providing an easy-to-use right-click menu for files in Windows.

It is possible to have a similar functionality in Linux. On my Ubuntu I am using Zenity. Zenity is a tool that allows to create nice GUI widgets and windows for shell scripts.

Here is a little bash script that you can save as CalcHash file and make it executable.

#!/bin/bash
# The script "CalcHash" calculates MD5 hash of a selected file.
# You can replace md5sum with sha1sum to calculate sha1 instead
title="CalcHash"
tmp_file="/tmp/md5-`date +'%s'`"
/usr/bin/md5sum $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS > $tmp_file
zenity --text-info --title="$title" --filename="$tmp_file" --width=1100 --height=100
rm $tmp_file
exit 0


To make the file executable just open gnome-terminal by clicking Applications > Accessories > Terminal. Then type:

chmod 755 CalcHash

or, if you prefer GUI, right-click on the file, select "Properties" click on the "Permissions" tab and then tick the appropriate box.

The script needs to be copied to /.Gnome2/nautilus-scripts.

You can go to Places > Home Folder

In Nautilus click Ctrl+H or just go to View and click Show Hidden Files

Navigate to .Gnome2 / nautilus-scripts and paste your script.

To calculate MD5 Hash, right click on any file or group of files and you should see something like this:

5 comments:

Unknown said...

I was unable to reach the site hosting Hashtab. Is there another location? Thanks for the info.

-Howard

Unknown said...

Do you have any idea how I could implement this in FileManager in Xfce? I'm using Slackware.

eco said...

Try http://www.softpedia.com/get/System/File-Management/HashTab.shtml

eco said...

Mate,
I haven't used Xfce since 1998, so my knowledge in this area is a little bit rusty :-)

I believe Xfce comes with Thunar file manager. My guess is that you should check "Edit" menu and "Configure custom actions" in Thunar.

Anonymous said...

Hmmm, good idea. I think it's a good idea to do that with strings too.