File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,13 @@ def file_hash(fname, alg="sha256"):
7878 )
7979 # Calculate the hash in chunks to avoid overloading the memory
8080 chunksize = 65536
81- hasher = ALGORITHMS_AVAILABLE [alg ]()
81+ # For hashlib algorithms, use usedforsecurity=False to support FIPS-enabled
82+ # systems. xxhash algorithms don't support this parameter.
83+ hasher = (
84+ ALGORITHMS_AVAILABLE [alg ](usedforsecurity = False )
85+ if alg in hashlib .algorithms_available
86+ else ALGORITHMS_AVAILABLE [alg ]()
87+ )
8288 with open (fname , "rb" ) as fin :
8389 buff = fin .read (chunksize )
8490 while buff :
Original file line number Diff line number Diff line change @@ -347,7 +347,7 @@ def unique_file_name(url: str) -> str:
347347 181a9d52e908219c2076f55145d6a344-data.txt.gz
348348
349349 """
350- md5 = hashlib .md5 (url .encode ()).hexdigest ()
350+ md5 = hashlib .md5 (url .encode (), usedforsecurity = False ).hexdigest ()
351351 fname = parse_url (url )["path" ].split ("/" )[- 1 ]
352352 # Crop the start of the file name to fit 255 characters including the hash
353353 # and the :
You can’t perform that action at this time.
0 commit comments