Permalink
Browse files

merge manpage conflict]

  • Loading branch information...
2 parents 2afb06b + f768488 commit 23bfd8cff59eb9104d04905cc74ca381d7b03c76 @mdomsch committed with Jul 13, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 S3/Utils.py
View
@@ -210,6 +210,21 @@ def mktmpfile(prefix = "/tmp/tmpfile-", randchars = 20):
return mktmpsomething(prefix, randchars, createfunc)
__all__.append("mktmpfile")
+def hash_file(filename):
+ """Given filename, return dict with hash types as keys, hashes as values"""
+ import hashlib
+ md5 = hashlib.md5()
+ f = open(filename, "rb")
+ while True:
+ # Hash 32kB chunks
+ data = f.read(32*1024)
+ if not data:
+ break
+ md5.update(data)
+ f.close()
+ return dict(md5=md5.hexdigest(), sha1=sha1.hexdigest(), sha256=sha256.hexdigest())
+
+
def hash_file_md5(filename):
h = md5()
f = open(filename, "rb")

0 comments on commit 23bfd8c

Please sign in to comment.