Upload utils.py
Browse files
utils.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import hashlib
|
| 2 |
+
|
| 3 |
+
def compute_sha1_from_file(file_path):
|
| 4 |
+
with open(file_path, "rb") as file:
|
| 5 |
+
bytes = file.read()
|
| 6 |
+
readable_hash = compute_sha1_from_content(bytes)
|
| 7 |
+
return readable_hash
|
| 8 |
+
|
| 9 |
+
def compute_sha1_from_content(content):
|
| 10 |
+
readable_hash = hashlib.sha1(content).hexdigest()
|
| 11 |
+
return readable_hash
|