imap-archiver/iarchiver/hash.py

17 lines
419 B
Python

import hashlib
import mmh3
def md5_chunked(data: bytes, size: int = 1024):
m = hashlib.md5()
for i in range(0, len(data), size):
m.update(data[i:i + size])
return m.hexdigest()
def murmur3_chunked(data: bytes, size: int = 1024):
hashes = [mmh3.hash(data[i:i + size]) for i in range(0, len(data), size)]
combined_hash = mmh3.hash(''.join(map(str, hashes)))
return str(combined_hash)