Saltar al contenido
uencoder

Contraseña Hashing Comparación

bcrypt, scrypt, Argon2, y PBKDF2 compared en memory hardness, cost parameters, y seguridad.

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
cost factor 12
scrypt
CPU and memory hard, tunable N/r/p
N=16384
Argon2id
Hybrid data-independent and dependent, PHC winner
m=64MB t=3 p=4
PBKDF2
CPU-only, iterated HMAC, NIST standardized
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.

Herramientas relacionadas

参考链接