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
2 changed files with 5 additions and 3 deletions

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()