give a file a unique id in python
November 24th, 2008 by Lawrence David
to hash a file’s contents in python, you can use the md5 module. this comes in handy if you want to screen a directory for duplicate files, for instance.
import md5
my_f = open(“my.file”)
my_s = my_f.read()
my_f.close()my_hash = md5.new(my_s).hexdigest()