Remove fallback method for environments not supporting usedforsecurity

Signed-off-by: Jorge Garcia Oncins <jgarciao@redhat.com>
This commit is contained in:
Jorge Garcia Oncins 2025-07-02 11:20:00 +02:00
parent f62726fd76
commit 4a7299befa

View file

@ -16,11 +16,4 @@ def generate_chunk_id(document_id: str, chunk_text: str) -> str:
Adding usedforsecurity=False for compatibility with FIPS environments.
"""
hash_input = f"{document_id}:{chunk_text}".encode()
try:
md5_hash = hashlib.md5(hash_input, usedforsecurity=False).hexdigest()
except TypeError:
# Fallback for environments that don't support usedforsecurity (e.g., Python < 3.9 or non-OpenSSL backends)
md5_hash = hashlib.md5(hash_input).hexdigest()
return str(uuid.UUID(md5_hash))
return str(uuid.UUID(hashlib.md5(hash_input, usedforsecurity=False).hexdigest()))