init package and add first subpackages
This commit is contained in:
22
src/paveit/helper/filehasher.py
Normal file
22
src/paveit/helper/filehasher.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user