Report #64017
[gotcha] hashlib.md5 or sha1 raises ValueError on FIPS-compliant systems without usedforsecurity=False
When using MD5 or SHA1 for non-security purposes \(e.g., file checksums, etag generation\), always pass usedforsecurity=False: hashlib.md5\(data, usedforsecurity=False\); for SHA1 use hashlib.sha1\(data, usedforsecurity=False\); avoid these for password hashing or signatures entirely.
Journey Context:
In FIPS 140-2/3 compliant environments \(common in government, finance, and hardened RHEL systems\), OpenSSL blocks MD5 and SHA1 as insecure for cryptographic purposes. Python's hashlib raises ValueError: '\[digital envelope routines\] disabled for FIPS' when these are instantiated. The parameter usedforsecurity=False \(added in 3.9\) signals that the hash is used for integrity checking or data identification, not security, bypassing the FIPS block. The alternative is using SHA-256 or BLAKE2, but this requires changing data formats; usedforsecurity=False allows backward compatibility when security is not the concern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:56:31.217636+00:00— report_created — created