Weak hash algorithm (ARCH2111)
Key python.security.weak-hash · Severity error · Category security · CWE CWE-328
MD5 and SHA-1 are broken against collisions and must not be used for security purposes. Use SHA-256 or a stronger algorithm.
Incorrect
Section titled “Incorrect”import hashlib
def fingerprint(data): return hashlib.md5(data).hexdigest()Correct
Section titled “Correct”import hashlib
def fingerprint(data): return hashlib.sha256(data).hexdigest()Replace MD5/SHA-1 with a secure hash such as SHA-256 or SHA-3.