diff options
Diffstat (limited to 'multihash')
-rw-r--r-- | multihash/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
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 |