Package de.mkammerer.argon2
Interface Argon2Advanced
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description byte[]generateSalt()Generates salt with the default length.byte[]generateSalt(int lengthInBytes)Generates salt with the specified length in bytes.java.lang.Stringhash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)Hashes a password, using the given salt.HashResulthashAdvanced(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int hashLength, Argon2Version version)Advanced version of hash, let the caller specify the hash length, the salt and the argon2 version.byte[]pbkdf(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int keyLength)Uses the given password to generate key material (password based key derivation).byte[]pbkdf(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt, int keyLength)Uses the given password to generate key material (password based key derivation).byte[]rawHash(int iterations, int memory, int parallelism, byte[] data, byte[] salt)Hashes the given data and returns the raw bytes.byte[]rawHash(int iterations, int memory, int parallelism, char[] password, byte[] salt)Hashes a password and returns the raw bytes.byte[]rawHash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)Hashes a password and returns the raw bytes.byte[]rawHash(int iterations, int memory, int parallelism, java.lang.String password, byte[] salt)Deprecated.Use therawHash(int, int, int, char[], byte[])method instead.byte[]rawHash(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset, byte[] salt)Deprecated.Use theArgon2.hash(int, int, int, char[], Charset)method instead.
-
-
-
Method Detail
-
rawHash
@Deprecated byte[] rawHash(int iterations, int memory, int parallelism, java.lang.String password, byte[] salt)Deprecated.Use therawHash(int, int, int, char[], byte[])method instead. Will be removed in version 3.Hashes a password and returns the raw bytes.Uses UTF-8 encoding.
- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashsalt- Salt to use. This will override the default salt length- Returns:
- Hashed password in raw bytes.
-
rawHash
@Deprecated byte[] rawHash(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset, byte[] salt)Deprecated.Use theArgon2.hash(int, int, int, char[], Charset)method instead. Will be removed in version 3.Hashes a password and returns the raw bytes.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashcharset- Charset of the passwordsalt- Salt to use. This will override the default salt length- Returns:
- Hashed password in raw bytes.
-
rawHash
byte[] rawHash(int iterations, int memory, int parallelism, char[] password, byte[] salt)Hashes a password and returns the raw bytes.Uses UTF-8 encoding.
- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashsalt- Salt to use. This will override the default salt length- Returns:
- Hashed password in raw bytes.
-
rawHash
byte[] rawHash(int iterations, int memory, int parallelism, byte[] data, byte[] salt)Hashes the given data and returns the raw bytes.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanesdata- Data to hashsalt- Salt to use. This will override the default salt length- Returns:
- Hashed data in raw bytes.
-
rawHash
byte[] rawHash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)Hashes a password and returns the raw bytes.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashcharset- Charset of the passwordsalt- Salt to use. This will override the default salt length- Returns:
- Hashed password in raw bytes.
-
pbkdf
byte[] pbkdf(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt, int keyLength)Uses the given password to generate key material (password based key derivation).- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to generate key material fromcharset- Charset of the passwordsalt- Salt to use. This will override the default salt lengthkeyLength- Length of the returned key material in bytes.- Returns:
- Key material.
-
pbkdf
byte[] pbkdf(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int keyLength)Uses the given password to generate key material (password based key derivation).- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to generate key material fromsalt- Salt to use. This will override the default salt lengthkeyLength- Length of the returned key material in bytes.- Returns:
- Key material.
-
hash
java.lang.String hash(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)Hashes a password, using the given salt.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashcharset- Charset of the passwordsalt- Salt- Returns:
- Hashed password.
-
hashAdvanced
HashResult hashAdvanced(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int hashLength, Argon2Version version)
Advanced version of hash, let the caller specify the hash length, the salt and the argon2 version. Returns both the encoded and the raw hash.- Parameters:
iterations- Number of iterationsmemory- Sets memory usage to x kibibytesparallelism- Number of threads and compute lanespassword- Password to hashsalt- Salt to use. This will override the default salt lengthhashLength- Length of the returned hash in bytes.version- Argon2 version- Returns:
- Hash result, containing both the raw and the encoded representation.
-
generateSalt
byte[] generateSalt()
Generates salt with the default length.- Returns:
- Salt.
-
generateSalt
byte[] generateSalt(int lengthInBytes)
Generates salt with the specified length in bytes.- Parameters:
lengthInBytes- Length of salt in bytes.- Returns:
- Salt.
-
-