SHA1 Hash in Right Click Menu

Minecraft’s file has a field for sha1 hash for resource packs. To use this, install nautilus-python and then copy this python script using any file name (such as into ~/.local/share/nautilus-python/extensions.  This provides a SHA-1 hash on the right click menu.

# Robert Knight, 

from gi.repository import Nautilus, GObject
import hashlib
import urllib

class Sha1Menu(GObject.GObject, Nautilus.MenuProvider):
    """ This places a SHA-1 sum in the context menu in Nautilus.
    To use it, nautilus-python is required.  This script then goes in
    ~/.local/share/nautilus-python/extensions and should work after a 
    restart of Nautilus
    def __init__(self):

    def menu_activate_cb(self, menu, file):
        print "menu_activate_cb",file

    def get_file_items(self, window, files):
        if len(files) != 1:

        file = files[0]
        filename = urllib.unquote(file.get_uri()[7:])
        sha1sum = hashlib.sha1()
        with open(filename,'rb') as f:
            for chunk in iter(lambda:, ''):
        string = sha1sum.hexdigest()
        item = Nautilus.MenuItem(name="Sha1Menu::Show_File_Name",
                                 label="SHA-1: %s" % string,
                                 tip="SHA-1: %s" % string)
        item.connect('activate', self.menu_activate_cb, file)
        return [item]

SHA-1 is not the most secure, but is the version used in the Minecraft server for resource pack hashing.