diff options
author | zyp <zyp@localhost> | 2006-10-19 17:11:00 +0200 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-10-19 17:11:00 +0200 |
commit | f93b71da9bcd01d7c1db797d9a84b95cbdabde0b (patch) | |
tree | dc16b47633ed53653ad7697a5785f05aaf0cb21a /multihash | |
parent | 77e467c9bae74863016e028008290e5f6fd1bca3 (diff) |
[project @ zyp-20061019151100-032626b43d2f238b]
[project @ 59]
Added hash_file-function.
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 |