diff options
author | zyp <zyp@localhost> | 2006-05-09 22:33:27 +0200 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-05-09 22:33:27 +0200 |
commit | 0c4fc1e72770fc78d87891e5c031272fca59e409 (patch) | |
tree | 10682cb815cff09ec1e2ce9beb619c916f08616c /multihash | |
parent | 373495b3a1c8ccdcfece70bac69625b6823ccec0 (diff) |
[project @ zyp-20060509203327-c8c93b489da2ea46]
[project @ 27]
Multihash library rewrite complete.
Diffstat (limited to 'multihash')
-rw-r--r-- | multihash/__init__.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/multihash/__init__.py b/multihash/__init__.py index 5bcf4d5..5e30186 100644 --- a/multihash/__init__.py +++ b/multihash/__init__.py @@ -1,11 +1,17 @@ -from _multihash import * +from _multihash import CRC32, Ed2k, MD5, SHA1 -def file_hash(name): - h = Multihash() - f = open(name) - data = f.read(32768) - while data: - h.update(data) - data = f.read(32768) - f.close() - return h
\ No newline at end of file +hashes = { + 'crc32': CRC32, + 'ed2k': Ed2k, + 'md5': MD5, + 'sha1': SHA1} + +class Multihash: + def __init__(self, *args): + if not args: + args = hashes.keys() + h = None + for hash in args: + h = hashes[hash](h) + setattr(self, hash, h.digest) + self.update = h.update |