Skip to content
Quantum-safe (classical)pbkdf2

PBKDF2

Derives a key or password hash by iterating HMAC many times; FIPS-approved and widely available.

Why it's safe

Quantum computers give little advantage against password hashing, because Grover's speed-up is offset by the cost of running a slow hash on quantum hardware. The practical risk is classical: too few iterations or a weak underlying hash. OWASP currently recommends 600,000 iterations for PBKDF2-HMAC-SHA256. Where FIPS is not required, a memory-hard function such as Argon2id resists GPU cracking better.

Used for
Key derivation
Family
Password-based key derivation
Standards
NIST SP 800-132, RFC 8018
Read the guideWhat encryption actually does

Migration guides

Concrete code changes to move off PBKDF2. Pick your stack.

hashlib / hmac / argon2-cffi · pythonPython: replace MD5 and SHA-1, and store passwords with Argon2idProduction-ready

Why

MD5 and SHA-1 collisions are practical with ordinary computers, so they are unsafe for signatures, integrity against attackers and password storage. Pick the replacement by purpose: SHA-256 for integrity, HMAC-SHA-256 for keyed authentication, Argon2id for passwords.

Before

python
import hashlib, hmac

digest = hashlib.md5(data).hexdigest()
tag = hmac.new(secret, payload, hashlib.sha1).hexdigest()
pw = hashlib.sha1((password + salt).encode()).hexdigest()   # never do this

After

python
import hashlib, hmac

digest = hashlib.sha256(data).hexdigest()

tag = hmac.new(secret, payload, hashlib.sha256).digest()
ok = hmac.compare_digest(tag, received_tag)                 # constant time

# Passwords: pip install argon2-cffi
from argon2 import PasswordHasher
ph = PasswordHasher()                                       # Argon2id with RFC 9106 low-memory defaults
stored = ph.hash(password)                                  # encodes params + salt + hash
ph.verify(stored, password)                                 # raises on mismatch
if ph.check_needs_rehash(stored):
    stored = ph.hash(password)

If you need MD5 for a non-security purpose (e.g. a legacy cache key), say so explicitly: hashlib.md5(data, usedforsecurity=False) (Python 3.9+). It also keeps FIPS-mode systems from rejecting the call.

Gotchas

  • PBKDF2 (hashlib.pbkdf2_hmac) is acceptable when FIPS is required; use SHA-256 with at least 600,000 iterations (OWASP guidance) and a 16-byte random salt.
  • Migrating passwords: re-hash on next login, or wrap old hashes (argon2id(old_sha1_hex)) right away and flag the records.
  • Django/Flask-Security etc. have their own hasher settings (PASSWORD_HASHERS); put Argon2 first rather than calling hashlib yourself.
  • External protocols that mandate HMAC-SHA1 (TOTP apps, some webhooks) can stay at that boundary.

Verify

npx -y pqe-cli scan . should show no remaining md5/sha1 findings outside intentional, documented spots.