From 29a4f9e8ea8c07e7bf8a7483ad031602f8a4f39c Mon Sep 17 00:00:00 2001 From: inference Date: Wed, 25 Jun 2025 21:38:34 +0000 Subject: [PATCH] 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. --- duplicate_check.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/duplicate_check.py b/duplicate_check.py index c5d18cf..00ad609 100644 --- a/duplicate_check.py +++ b/duplicate_check.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Duplicate Check -# Version: 0.8.0 +# Version: 0.9.0 # Copyright 2025 Jake Winters # SPDX-License-Identifier: BSD-3-Clause @@ -9,3 +9,11 @@ import os 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()