SHA1 (secure hash algorithm)    (http://en.wikipedia.org/wiki/SHA-1)

• Cryptographic has function

• Designed by US National Security Agency.

• Is a standard

• Is a 40 digit hash value in hexadecimal

• It's purely a consistency check

 

 


Git calculates the SHA1 for a file.

sha1( "blob" + filesize + "\0" + data )

sha1( "blob" 7\0foobar\n" ) = "323fae03f4606ea9991df8befbb2fca795e648fa"

 


Python implementation

sha1sum.py

from hashlib import sha1
def githash(data):
    s = sha1()
    s.update("blob %u\0" % len(data))
    s.update(data)
    return s.hexdigest()

In the Terminal Shell

python -c "from sha1sum import *; print hashfile('delme.txt')"