Skip to content

Commit dda61ca

Browse files
committed
MAINT: Use SHA-256 instead of SHA-1
While the use of SHA-1 here hardly poses any risks, its use will eventually be prohibited globally in FIPS-compliant operating systems such as RHEL, and I don't see any downsides in moving away from using it. Signed-off-by: Nikola Forró <[email protected]>
1 parent dc7dafe commit dda61ca

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/cythonize.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def process_tempita_pxd(fromfile, tofile):
135135
# Hash db
136136
#
137137
def load_hashes(filename):
138-
# Return { filename : (sha1 of input, sha1 of output) }
138+
# Return { filename : (sha256 of input, sha256 of output) }
139139
if os.path.isfile(filename):
140140
hashes = {}
141141
with open(filename, 'r') as f:
@@ -151,8 +151,8 @@ def save_hashes(hash_db, filename):
151151
for key, value in sorted(hash_db.items()):
152152
f.write("%s %s %s\n" % (key, value[0], value[1]))
153153

154-
def sha1_of_file(filename):
155-
h = hashlib.sha1()
154+
def sha256_of_file(filename):
155+
h = hashlib.sha256()
156156
with open(filename, "rb") as f:
157157
h.update(f.read())
158158
return h.hexdigest()
@@ -168,8 +168,8 @@ def normpath(path):
168168
return path
169169

170170
def get_hash(frompath, topath):
171-
from_hash = sha1_of_file(frompath)
172-
to_hash = sha1_of_file(topath) if os.path.exists(topath) else None
171+
from_hash = sha256_of_file(frompath)
172+
to_hash = sha256_of_file(topath) if os.path.exists(topath) else None
173173
return (from_hash, to_hash)
174174

175175
def process(path, fromfile, tofile, processor_function, hash_db):

0 commit comments

Comments
 (0)