Passwort Hashing Vergleich
bcrypt, scrypt, Argon2, und PBKDF2 compared auf memory hardness, cost parameters, und Sicherheit.
Algorithm Overview
Password hashing functions deliberately consume significant CPU and memory to slow brute-force attacks. bcrypt is CPU-hard with a fixed 4 KB memory footprint and a maximum 72-byte password limit. scrypt adds memory hardness to also hinder GPU and ASIC attacks. Argon2, the PHC winner, offers tunable parallelism, memory, and time parameters. PBKDF2 is CPU-only and widely standardized but less resistant to GPU attacks.
- bcrypt
- CPU-hard, 4 KB memory, 72-byte password limit
- scrypt
- CPU and memory hard, tunable N/r/p
- Argon2id
- Hybrid data-independent and dependent, PHC winner
- PBKDF2
- CPU-only, iterated HMAC, NIST standardized
cost factor 12 N=16384 m=64MB t=3 p=4 iterations 600000 Parameter Tuning
Parameters should be tuned so that a single hash takes an acceptable user-facing latency, typically 100 to 500 milliseconds. bcrypt cost increases exponentially, so incrementing the cost by 1 doubles the time. Argon2 parameters are linear in memory and time, offering finer control. Parameters must be stored alongside the hash so verification uses the same settings, and they can be upgraded over time.
Migration Strategy
Upgrading password hashes when algorithms are deprecated is done lazily on user login. When a user authenticates with the old hash, verify it, then re-hash the plaintext password with the new algorithm and store the result. This avoids forcing a password reset for all users. Never store plaintext passwords even temporarily during migration. Log migration progress to track how many accounts remain on the old scheme.