1
0
mirror of synced 2026-08-06 02:08:01 +00:00

Add Argon2PasswordEncoder

Add PasswordEncoder for the Argon2 hashing algorithm (Password Hashing
Competition (PHC) winner).
This implementation uses the BouncyCastle-implementation of Argon2.

Fixes gh-5354
This commit is contained in:
Simeon Macke
2019-06-27 13:44:15 +02:00
committed by Rob Winch
parent 1b1e45a1ef
commit b3da1e466b
7 changed files with 706 additions and 2 deletions
@@ -265,6 +265,23 @@ String result = encoder.encode("myPassword");
assertTrue(encoder.matches("myPassword", result));
----
[[pe-a2pe]]
== Argon2PasswordEncoder
The `Argon2PasswordEncoder` implementation uses the https://en.wikipedia.org/wiki/Argon2[Argon2] algorithm to hash the passwords.
Argon2 is the winner of the https://en.wikipedia.org/wiki/Password_Hashing_Competition[Password Hashing Competition].
In order to defeat password cracking on custom hardware, Argon2 is a deliberately slow algorithm that requires large amounts of memory.
Like other adaptive one-way functions, it should be tuned to take about 1 second to verify a password on your system.
The current implementation if the `Argon2PasswordEncoder` requires BouncyCastle.
[source,java]
----
// Create an encoder with all the defaults
Argon2PasswordEncoder encoder = new Argon2PasswordEncoder();
String result = encoder.encode("myPassword");
assertTrue(encoder.matches("myPassword", result));
----
[[pe-pbkdf2pe]]
== Pbkdf2PasswordEncoder