Class Argon2Hash
java.lang.Object
br.net.dd.netherwingcore.common.cryptography.Argon2Hash
Utility class for hashing and verifying passwords using the Argon2 algorithm.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionHashes a password using the Argon2 algorithm with the provided salt and default parameters.Hashes a password using the Argon2 algorithm with the provided parameters.static booleanVerifies a password against an encoded hash.
-
Field Details
-
HASH_LEN
public static final int HASH_LEN- See Also:
-
ENCODED_HASH_LEN
public static final int ENCODED_HASH_LEN- See Also:
-
DEFAULT_ITERATIONS
public static final int DEFAULT_ITERATIONS- See Also:
-
DEFAULT_MEMORY_COST
public static final int DEFAULT_MEMORY_COST- See Also:
-
PARALLELISM
public static final int PARALLELISM- See Also:
-
-
Method Details
-
hash
Hashes a password using the Argon2 algorithm with the provided salt and default parameters.- Parameters:
password- The password to hash.saltBytes- The salt to use for hashing.- Returns:
- An Optional containing the encoded hash if successful, or an empty Optional if an error occurs.
-
hash
public static Optional<String> hash(String password, byte[] saltBytes, int nIterations, int kibMemoryCost) Hashes a password using the Argon2 algorithm with the provided parameters.- Parameters:
password- The password to hash.saltBytes- The salt to use for hashing.nIterations- The number of iterations to perform.kibMemoryCost- The memory cost in KiB.- Returns:
- An Optional containing the encoded hash if successful, or an empty Optional if an error occurs.
-
verify
-