Files
lib-paveit-demo/src/paveit/helper/filehasher.py
2023-03-17 14:54:19 +01:00

23 lines
381 B
Python
Executable File

import hashlib
from io import BytesIO
def calc_hash_of_bytes(buf: BytesIO):
""" calculate the hash of the file """
algo = hashlib.sha1()
buffer_size = 65536
buffer_size = buffer_size * 1024 * 1024
while True:
data = buf.read(buffer_size)
if not data:
break
algo.update(data)
hex = algo.hexdigest()
return hex