phxql / argon2-jvm

Argon2 Binding for the JVM
GNU Lesser General Public License v3.0
331 stars 33 forks source link

How to specify the salt value? #91

Closed jpstotz closed 3 years ago

jpstotz commented 3 years ago

The current Argon2 interface has no method for executing Argon2 with a custom selected salt as it is needed for key derivation.

Please provide a method that allows to specify the salt value and returns the generated byte[] for example:

byte[] hash(int iterations, int memory, int parallelism, byte[] salt, byte[] data);

jpstotz commented 3 years ago

Seems like this feature is a bit hidden, I finally found it:

Argon2Advanced argon2 = Argon2Factory.createAdvanced();
HashResult result = argon2.hashAdvanced(iterations, memory, parallelism, pwd, salt, 80, Argon2Version.V13);
byte[] output = result.getRaw();
phxql commented 3 years ago

If you need key derivation, you can also take a look at de.mkammerer.argon2.Argon2Advanced#pbkdf, which is a password based key derivation.