Add: complete change for last commit
This commit is contained in:
parent
94a0dc1001
commit
5806519e01
1 changed files with 28 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue