Hash/Crittografia
Bcrypt Hash + Verify
Applica l'hash alle password con bcrypt (con salt casuale e costo configurabile) e verifica una password rispetto a un hash bcrypt esistente.
Bcrypt is a deliberately slow password-hashing algorithm: unlike MD5 or SHA-256, it intentionally requires heavy computation so that brute-forcing passwords stays impractical even if a database of hashes leaks.
How to use it
- Hash: enter a password and set a cost factor — a higher number means slower, more secure hashing.
- Every hash call generates a fresh random salt, so the same password produces a different hash each time — that's expected and normal.
- Verify: paste a password and an existing bcrypt hash to check whether they match, without hashing manually yourself.
Common uses
- Manually checking that a backend hashes passwords correctly before storing them.
- Generating a test bcrypt hash for seed data or fixtures during development.
- Debugging a failed login by comparing an entered password against the stored hash.
Things to keep in mind
Pick a cost factor that keeps hashing around 100-300ms on your target server — a balance between security and login-time load.
Bcrypt truncates passwords longer than 72 bytes — characters beyond that limit are ignored by the algorithm.
Articolo su questo strumento: Bcrypt: perché le password vengono hashate lentamente, non velocemente
Domande frequenti
Perché bcrypt include un fattore di "costo" o "rounds"?
Il fattore di costo controlla quante volte l'hashing viene ripetuto internamente, quindi l'hashing diventa esponenzialmente più lento all'aumentare del valore. Questo permette di mantenerlo deliberatamente abbastanza lento da resistere agli attacchi brute-force anche quando l'hardware diventa più veloce.
Perché l'hash bcrypt ha sempre la stessa lunghezza indipendentemente dalla mia password?
Bcrypt genera un hash di lunghezza fissa (tipicamente 60 caratteri) che codifica insieme versione dell'algoritmo, fattore di costo, salt e hash — la lunghezza non dipende da quanto è lunga o corta la password originale.
Bcrypt ha bisogno di un campo salt separato?
No. Il salt viene generato automaticamente e incorporato direttamente nella stringa di output, quindi non devi memorizzarlo o gestirlo separatamente — è sempre incluso quando verifichi una password rispetto all'hash.
C'è un limite alla lunghezza della password in bcrypt?
Sì, bcrypt elabora solo i primi 72 byte della password — tutto ciò che è più lungo viene semplicemente scartato senza avviso. In pratica questo è raramente un problema, ma vale la pena ricordarlo quando si lavora con password molto lunghe o caratteri non-ASCII, dove un carattere può occupare più byte.
Perché bcrypt è ancora consigliato se esiste Argon2?
Bcrypt è stato testato in pratica per decenni, è ampiamente supportato in tutti i linguaggi e framework e resta una scelta del tutto affidabile. Argon2 è consigliato come prioritario per i nuovi sistemi per la protezione dagli attacchi su GPU/ASIC, ma bcrypt non è considerato insicuro — solo meno resistente a hardware specializzato.