Feed on
Posts
Comments

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()


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.