This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
RepoApi/utils/Tools.py

13 lines
377 B
Python

def hash_bytestr_iter(bytesiter, hasher, ashexstr=False):
for block in bytesiter:
hasher.update(block)
return hasher.hexdigest() if ashexstr else hasher.digest()
def file_as_blockiter(afile, blocksize=65536):
with afile:
block = afile.read(blocksize)
while len(block) > 0:
yield block
block = afile.read(blocksize)