From f93b71da9bcd01d7c1db797d9a84b95cbdabde0b Mon Sep 17 00:00:00 2001 From: zyp Date: Thu, 19 Oct 2006 15:11:00 +0000 Subject: [project @ zyp-20061019151100-032626b43d2f238b] [project @ 59] Added hash_file-function. --- multihash/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'multihash') diff --git a/multihash/__init__.py b/multihash/__init__.py index 5e30186..9be422f 100644 --- a/multihash/__init__.py +++ b/multihash/__init__.py @@ -1,4 +1,4 @@ -from _multihash import CRC32, Ed2k, MD5, SHA1 +from _multihash import CRC32, Ed2k, MD5, SHA1, _hash_file hashes = { 'crc32': CRC32, @@ -15,3 +15,10 @@ class Multihash: h = hashes[hash](h) setattr(self, hash, h.digest) self.update = h.update + self.first = h + +def hash_file(name, *args): + f = open(name) + h = Multihash() + _hash_file(f.fileno(), h.first) + return h \ No newline at end of file -- cgit v1.2.3