fix: usage of hashlib for FIPS (#1512)

fix usage of hashlib for FIPS

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
Michele Dolfi 2025-05-02 15:03:29 +02:00 committed by GitHub
parent de56523974
commit 7c705739f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -189,7 +189,9 @@ class DocumentConverter:
def _get_pipeline_options_hash(self, pipeline_options: PipelineOptions) -> str:
"""Generate a hash of pipeline options to use as part of the cache key."""
options_str = str(pipeline_options.model_dump())
return hashlib.md5(options_str.encode("utf-8")).hexdigest()
return hashlib.md5(
options_str.encode("utf-8"), usedforsecurity=False
).hexdigest()
def initialize_pipeline(self, format: InputFormat):
"""Initialize the conversion pipeline for the selected format."""

View File

@ -20,7 +20,7 @@ def create_file_hash(path_or_stream: Union[BytesIO, Path]) -> str:
"""Create a stable page_hash of the path_or_stream of a file"""
block_size = 65536
hasher = hashlib.sha256()
hasher = hashlib.sha256(usedforsecurity=False)
def _hash_buf(binary_stream):
buf = binary_stream.read(block_size) # read and page_hash in chunks
@ -38,7 +38,7 @@ def create_file_hash(path_or_stream: Union[BytesIO, Path]) -> str:
def create_hash(string: str):
hasher = hashlib.sha256()
hasher = hashlib.sha256(usedforsecurity=False)
hasher.update(string.encode("utf-8"))
return hasher.hexdigest()