Add: complete change for last commit

This commit is contained in:
Aroy-Art 2025-02-24 19:05:06 +01:00
parent 94a0dc1001
commit 5806519e01
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -1 +1,29 @@
from blake3 import blake3
from tqdm.auto import tqdm
def compute_file_hash_black3(self, file_path):
"""Compute BLAKE3 hash of the file"""
try:
hasher = blake3()
with open(file_path, "rb") as f:
while chunk := f.read(65536):
hasher.update(chunk)
return hasher.hexdigest()
except Exception as e:
# self.stdout.write(self.style.WARNING(f"Error computing file hash: {e}"))
tqdm.write(self.style.WARNING(f"Error computing file hash: {e}"))
return None
def compute_string_hash_black3(self, string):
"""Compute BLAKE3 hash of the string"""
try:
hasher = blake3()
hasher.update(string.encode())
return hasher.hexdigest()
except Exception as e:
# self.stdout.write(self.style.WARNING(f"Error computing string hash: {e}"))
tqdm.write(self.style.WARNING(f"Error computing string hash: {e}"))
return None