Package de.mkammerer.argon2
Interface Argon2
-
- All Known Subinterfaces:
Argon2Advanced
public interface Argon2Argon2 password hashing function.All implementing classes need to be thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.lang.Stringhash(int iterations, int memory, int parallelism, byte[] data)Hashes the given data.java.lang.Stringhash(int iterations, int memory, int parallelism, char[] password)Hashes a password.java.lang.Stringhash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset)Hashes a password.java.lang.Stringhash(int iterations, int memory, int parallelism, java.lang.String password)Deprecated.Use thehash(int, int, int, char[])method instead.java.lang.Stringhash(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset)Deprecated.Use thehash(int, int, int, char[], Charset)method instead.booleanneedsRehash(java.lang.String hash, int iterations, int memory, int parallelism)Checks if the given hash uses obsolete parameters like iterations, memory, parallelism.booleanverify(java.lang.String hash, byte[] data)Verifies the given data against a hash.booleanverify(java.lang.String hash, char[] password)Verifies a password against a hash.booleanverify(java.lang.String hash, char[] password, java.nio.charset.Charset charset)Verifies a password against a hash.booleanverify(java.lang.String hash, java.lang.String password)Deprecated.Use theverify(String, char[])method instead.booleanverify(java.lang.String hash, java.lang.String password, java.nio.charset.Charset charset)Deprecated.Use theverify(String, char[], Charset)method instead.voidwipeArray(byte[] array)Wipes the data from the given array.voidwipeArray(char[] array)Wipes the data from the given array.
-
-
-
Method Detail
-
hash
@Deprecated java.lang.String hash(int iterations, int memory, int parallelism, java.lang.String password)Deprecated.Use thehash(int, int, int, char[])method instead. Will be removed in version 3.Hashes a password.Uses UTF-8 encoding.
- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hash- Returns:
- Hashed password.
-
hash
@Deprecated java.lang.String hash(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset)Deprecated.Use thehash(int, int, int, char[], Charset)method instead. Will be removed in version 3.Hashes a password.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashcharset- Charset of the password- Returns:
- Hashed password.
-
hash
java.lang.String hash(int iterations, int memory, int parallelism, char[] password)Hashes a password.Uses UTF-8 encoding.
- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hash- Returns:
- Hashed password.
-
hash
java.lang.String hash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset)Hashes a password.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashcharset- Charset of the password- Returns:
- Hashed password.
-
hash
java.lang.String hash(int iterations, int memory, int parallelism, byte[] data)Hashes the given data.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanesdata- Data to hash- Returns:
- Hashed data.
-
verify
@Deprecated boolean verify(java.lang.String hash, java.lang.String password)Deprecated.Use theverify(String, char[])method instead. Will be removed in version 3.Verifies a password against a hash.Uses UTF-8 encoding.
- Parameters:
hash- Hash.password- Password.- Returns:
- True if the password matches the hash, false otherwise.
-
verify
@Deprecated boolean verify(java.lang.String hash, java.lang.String password, java.nio.charset.Charset charset)Deprecated.Use theverify(String, char[], Charset)method instead. Will be removed in version 3.Verifies a password against a hash.- Parameters:
hash- Hash.password- Password.charset- Charset of the password- Returns:
- True if the password matches the hash, false otherwise.
-
verify
boolean verify(java.lang.String hash, char[] password)Verifies a password against a hash.Uses UTF-8 encoding.
- Parameters:
hash- Hash.password- Password.- Returns:
- True if the password matches the hash, false otherwise.
-
verify
boolean verify(java.lang.String hash, char[] password, java.nio.charset.Charset charset)Verifies a password against a hash.- Parameters:
hash- Hash.password- Password.charset- Charset of the password- Returns:
- True if the password matches the hash, false otherwise.
-
verify
boolean verify(java.lang.String hash, byte[] data)Verifies the given data against a hash.- Parameters:
hash- Hash.data- Data.- Returns:
- True if the data matches the hash, false otherwise.
-
wipeArray
void wipeArray(char[] array)
Wipes the data from the given array.Use this method after hash creation / verification on the array which contains the user password.
- Parameters:
array- The array to wipe.
-
wipeArray
void wipeArray(byte[] array)
Wipes the data from the given array.Use this method after hash creation / verification on the array which contains the user password.
- Parameters:
array- The array to wipe.
-
needsRehash
boolean needsRehash(java.lang.String hash, int iterations, int memory, int parallelism)Checks if the given hash uses obsolete parameters like iterations, memory, parallelism.If one of the hash's parameters doesn't match the required minimum, this method will return true.
- Parameters:
hash- a hash created byhashiterations- number of minimum iterationsmemory- minimum memory usageparallelism- minimum of parallelism- Returns:
trueif the hash should be rehashed to match the given parameters, orfalseotherwise.- Throws:
java.lang.IllegalArgumentException- if the hash is invalid
-
-