Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- def calculate_zerobytes_md5(size):
- def multiple(value):
- results = []
- for unit in (0, 1, 2):
- for multi in (16, 32, 64, 128, 256, 512):
- result = value / multi / (1024 ** unit)
- if result.is_integer():
- results.append(multi * 1024 ** unit)
- return results[-1]
- chunk_size = multiple(size)
- zerobytes = b"\x00" * chunk_size
- iterations = size // chunk_size
- md5 = hashlib.md5()
- for _ in range(iterations):
- md5.update(zerobytes)
- return md5.hexdigest()
- # >>> calculate_zerobytes_md5(7743733760)
- # '30e109af780fd3763a013b4adf3ceb71'
- # >>> calculate_zerobytes_md5(0)
- # 'd41d8cd98f00b204e9800998ecf8427e'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement