From 5806519e01c7c43c82cb12407f98086f5f39c03a Mon Sep 17 00:00:00 2001
From: Aroy-Art <Aroy-Art@pm.me>
Date: Mon, 24 Feb 2025 19:05:06 +0100
Subject: [PATCH] Add: complete change for last commit

---
 backend/utils/hash.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/backend/utils/hash.py b/backend/utils/hash.py
index e044290..d3910df 100644
--- a/backend/utils/hash.py
+++ b/backend/utils/hash.py
@@ -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