from _multihash import CRC32, Ed2k, MD5, SHA1, _hash_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 self.first = h def hash_file(name, algorithms): f = open(name) h = Multihash(*algorithms) _hash_file(f.fileno(), h.first) return h