OWASP Password Hashing Recommendations 2025 – Java Security
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
OWASP's current password-storage guidance prefers Argon2id. One listed minimum uses 19 MiB of memory, 2 iterations, and parallelism 1, and the cheat sheet also lists other memory-and-time combinations. The service should benchmark its chosen profile under real authentication load.
If Argon2id is unavailable, OWASP recommends scrypt. bcrypt is retained mainly for legacy systems where Argon2id and scrypt cannot be used; its cost should be at least 10 under the cited guidance, and it has a 72-byte password-input limit. For environments that require FIPS-validated cryptography, OWASP lists PBKDF2-HMAC-SHA-256 with at least 600,000 iterations.
Each verifier needs a unique salt, normally generated and encoded by the library. Store the algorithm and parameters with the hash, monitor guidance, and upgrade successful logins when policy changes. The published settings are a floor, not a permanent one-size-fits-all target.
OWASP Password Hashing Recommendations 2025 – Java Security
Direct Answer
OWASP's 2025 Password Storage guidance prefers Argon2id, with one listed minimum configuration of 19 MiB memory, 2 iterations, and parallelism 1. If Argon2id is unavailable, use scrypt with a recommended cost profile. bcrypt with cost 10 or more is mainly for legacy systems where Argon2id and scrypt are unavailable; remember its 72-byte limit. For FIPS-validated environments, OWASP lists PBKDF2-HMAC-SHA-256 with 600,000 or more iterations. Benchmark, use unique salts, and migrate as guidance changes.
Code Example
@Bean
PasswordEncoder passwordEncoder() {
return new Argon2PasswordEncoder(
16, // salt length in bytes
32, // output length in bytes
1, // parallelism
19 * 1024, // memory in KiB
2); // iterations
}
This matches one OWASP-listed minimum. Load-test it on the deployment platform, consider stronger settings when capacity allows, and use an encoded/delegating format so future policy changes can migrate existing verifiers.
Common Mistakes & Pitfalls
- Not using Argon2id when available: Many freshers default to bcrypt because it's in tutorials, unaware OWASP now prefers Argon2id for its memory-hardness advantage against GPU attacks.
- Using too-low cost factors: Setting bcrypt cost to 4-6 or PBKDF2 iterations below 100,000 makes hashing too fast—attackers can brute-force efficiently. OWASP minimums exist because hardware gets faster every year.
- Forgetting unique salts: Using a global salt or no salt lets attackers crack multiple passwords at once with precomputed tables. Every password must have its own random salt generated at hash time.
Check your understanding
Answer these without looking back at the article.
- What does 'memory-hard' mean and why does it matter for password cracking?
- How would you upgrade from bcrypt to Argon2 without forcing all users to change passwords?
- What is FIPS compliance and why does it affect password hashing algorithm choices?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.