Hash/Crittografia
Argon2 Hash + Verify
Applica l'hash alle password con Argon2 (vincitore della Password Hashing Competition, RFC 9106) — varianti d/i/id, con verifica rispetto a un hash esistente.
Argon2 is the Password Hashing Competition winner and the algorithm recommended in RFC 9106 for hashing passwords. Unlike bcrypt, it deliberately demands a lot of memory, not just CPU time, which makes attacks on specialized hardware (GPUs, ASICs) much harder.
How to use it
- Hash: enter a password, pick a variant (Argon2d, Argon2i, or Argon2id), and set the parameters (memory, iterations, parallelism) to get a hash.
- Verify: paste a password and an existing Argon2 hash to check whether they match, without hashing manually yourself.
- Argon2id is the recommended default for most applications — it combines the strengths of Argon2i and Argon2d.
Common uses
- Checking that a backend generates correct Argon2 hashes with the expected parameters before a release.
- Tuning memory and iteration parameters to fit within a server's response-time budget (typically 250-500ms).
- Comparing Argon2 against bcrypt or PBKDF2 when choosing an algorithm for a new project.
Things to keep in mind
The memory parameter is Argon2's main defense: the more memory hashing requires, the more expensive it is for an attacker to parallelize an attack on a GPU with limited fast memory per chip.
Argon2id is recommended for most cases: Argon2i resists side-channel attacks better, Argon2d resists GPU attacks better, and id combines both approaches.
Domande frequenti
Perché Argon2 è consigliato rispetto ad hash più vecchi come MD5 o SHA-256 per le password?
Argon2 è deliberatamente lento e richiede molta memoria, rendendo il brute-force e il cracking basato su GPU/ASIC molto più costosi, a differenza di hash generici veloci come MD5 o SHA-256, inadatti a conservare le password.
Cosa controllano i parametri di memoria, iterazioni e parallelismo?
Il costo di memoria stabilisce quanta RAM richiede ogni tentativo di hash, le iterazioni controllano quanti passaggi vengono eseguiti, e il parallelismo il numero di thread — aumentare uno qualsiasi alza il costo del cracking a scapito di un hashing più lento.
Quale variante di Argon2 dovrei usare — d, i o id?
Argon2id è la variante predefinita consigliata per l'hashing delle password, poiché combina la resistenza di Argon2i agli attacchi side-channel con la resistenza di Argon2d al cracking via GPU.
Da dove viene Argon2 come standard?
Argon2 ha vinto la Password Hashing Competition del 2015 — una competizione aperta di crittografi il cui obiettivo era trovare il miglior algoritmo per l'hashing delle password. Da allora OWASP lo raccomanda come scelta prioritaria rispetto a bcrypt.
Il parametro di parallelismo accelera solo l'hashing?
No, lo stesso parametro accelera allo stesso modo il brute-force per un attaccante con hardware multi-core, quindi il parallelismo va scelto in base al numero reale di core del server, non aumentato senza necessità.