feat(hash): add SHA-256 hashing functionality

Add SHA-256-based hashing for files and store the values in a
dictionary for later use with the detection-and-deletion function.
This commit is contained in:
inference 2025-06-25 21:38:34 +00:00
parent 72d7057cfd
commit 29a4f9e8ea
Signed by: inference
SSH Key Fingerprint: SHA256:/O3c09/4f1lh4zrhFs2qvQEDda6dZbTwG9xEcj8OfWo

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# Duplicate Check # Duplicate Check
# Version: 0.8.0 # Version: 0.9.0
# Copyright 2025 Jake Winters # Copyright 2025 Jake Winters
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
@ -9,3 +9,11 @@
import os import os
import hashlib import hashlib
def hash_file(file_path):
sha256_hash = hashlib.sha256()
with open(file_path, 'rb') as f:
for byte_block in iter(lambda: f.read(65536), b''):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()