Skip to content

Instantly share code, notes, and snippets.

@gcollazo
Created July 7, 2011 12:54
Show Gist options
  • Save gcollazo/1069442 to your computer and use it in GitHub Desktop.
Save gcollazo/1069442 to your computer and use it in GitHub Desktop.
from hashlib import sha1
def main():
print hashfile("~/Desktop/lift-columns.png")
def hashfile(path):
f = open(path)
file_hash = githash(f.read())
f.close()
return file_hash
def githash(data):
s = sha1()
s.update("blob %u\0" % len(data))
s.update(data)
return s.hexdigest()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment