6

I use Hashtab in Windows to compute the hash of a file. All I have to do is right click on the file, click properties and in the properties menu there would be a tab called Hash and it contains the hash of the file in different formats like MD5, SHA-1 etc.

Is there something like that for Ubuntu?

6

You don't say what window manager or file manager you're using.

If you're using Gnome and Nautilus you can install nautilus-gtkhash Install nautilus-gtkhash package. This adds a "Digests" tab to the Properties dialog for a file.

NOTE: You will have to restart Nautilus with nautilus -q before the tab will appear.

  • @Ufoguy: Please remember to mark answers as Accepted when they work out for you. Thanks! – Phoeey Sep 15 '13 at 10:34
  • How do I do that? – Ufoguy Sep 19 '13 at 7:18
  • Takkat edited my answer to put the link to the nautilus-gtkhash package in. Use Synaptic to install it, or from a Terminal type: <code>sudo apt-get install -y nautilus-gtkhash; nautilus -q</code> – Phoeey Sep 20 '13 at 1:30
0

You could also try this "Hash Checker"

http://gnome-look.org/content/download.php?content=129309&id=1&tan=39290839

HowTo-

HOW TO INSTALL/UNINSTALL From GUI: Just run ‘Setup’ script and follow the instructions. From terminal: cd into Hash Checker’s folder and type ‘./Setup –help’ (without quotes) to see available language switches

USAGE Using with Nautilus: Right-click somewhere in Nautilus, go to Scripts > Check hash(es) then browse to the file you want to check or (to avoid browsing for a file) just right-click on the file you want to check then go to Scripts > Check hash(es). Using with any File Manager: Click at the Hash Checker’s desktop icon to run it, then browse to the file you want to check

DEPENDENCIES Zenity (for displaying GUI) md5sum and sha256sum (most distros have them both by default)

I got it from this site

http://ubuntuguide.net/md5sha256-hash-checker-gui-for-ubuntu-downloadsfiles

You can also see this

http://www.sinf.gr/en/hashcalc.html

This was mentioned in the comments of the first site.

0

One desktop-independent solution is GtkHash:

A GTK+ utility for computing message digests or checksums

enter image description here

If you're using Thunar, then you may as well use the thunar-gtkhash plugin. It works similarly to the Nautilus extension.

0

Custom Nautilus Script

While there are a few existing utilities, one can always write a script to perform such task, which is what I did. The script presented below is written in Python 3 and uses built-in functions to perform hash sum calculations of multiple types of hash, and displays the result in zenity text view window.

Usage

First set up the script. Save the script source code as file in ~/.local/share/nautilus/scripts folder. In my example, I've saved it as get_hashsums.py. Make the file executable via GUI options or via chmod +x command in terminal.

At this point the script is accessible via right-click menu, and will be available in Scripts submenu.

enter image description here

When you click on the get_hashsums.py , the script will perform all the necessary calculations and display zenity text view window with all hash sums that can be done via hashlib.

enter image description here

Script Source code

Also available on my personal GitHub repository ( which may contain more features added ).

#!/usr/bin/env python3
import sys
import urllib.parse
import hashlib
import os
import subprocess
import tempfile
from collections import OrderedDict as od

def get_hashsums(file_path):
    hash_sums = od()
    hash_sums['md5sum'] = hashlib.md5()
    hash_sums['sha1sum'] = hashlib.sha1()
    hash_sums['sha224sum'] = hashlib.sha224()
    hash_sums['sha256sum'] = hashlib.sha256()
    hash_sums['sha384sum'] = hashlib.sha384()
    hash_sums['sha512sum'] = hashlib.sha512()

    with open(file_path, 'rb') as fd:
        data_chunk = fd.read(1024)
        while data_chunk:
              for hashsum in hash_sums.keys():
                  hash_sums[hashsum].update(data_chunk)
              data_chunk = fd.read(1024)

    results = od()
    for key,value in hash_sums.items():
         results[key] = value.hexdigest()         
    return results

def puke(message):
    sys.stderr.write(message + '\n')
    subprocess.call(['zenity', '--error', '--text', message])
    sys.exit(2)

def write_temp_file(data):
    temp = tempfile.mkstemp()[1]
    with open(temp, 'w') as fd:
        fd.write(data)
    return temp


def main():
    uri_list = os.getenv("NAUTILUS_SCRIPT_SELECTED_URIS").strip().split()
    output_lines = []
    for uri in uri_list:
        uri_decoded = urllib.parse.unquote(uri)
        path = uri_decoded.replace('file://','').strip()
        if not os.path.isfile(path):
             puke(path+" is not a regular file")
        text = ""
        text = path + "\n" 
        hashsums = get_hashsums(path)
        for key,value in hashsums.items():
              text = text + key + " " + value + "\n"
        output_lines.append(text)

    output_file = write_temp_file("\n".join(output_lines))
    subprocess.call(['zenity','--text-info',
                     '--title','Hash Sums',
                     '--filename',output_file])
    os.unlink(output_file)

if __name__ == '__main__': 
    try:
        main()
    except Exception as e:
        puke(repr(e))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.