Package org.frankframework.util
Class PasswordHash
java.lang.Object
org.frankframework.util.PasswordHash
PBKDF2 salted password hashing.
Author: havoc AT defuse.ca
www: http://crackstation.net/hashing-security.htm
Password Hashing With PBKDF2 (http://crackstation.net/hashing-security.htm).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final Stringstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateHash(char[] password) Returns a salted PBKDF2 hash of the password.static StringcreateHash(char[] password, int iterations) static StringcreateHash(String password) Returns a salted PBKDF2 hash of the password.static booleanvalidatePassword(char[] password, String correctHash) Validates a password using a hash.static booleanvalidatePassword(String password, String correctHash) Validates a password using a hash.
-
Field Details
-
PBKDF2_ALGORITHM
- See Also:
-
SALT_BYTE_SIZE
public static final int SALT_BYTE_SIZE- See Also:
-
HASH_BYTE_SIZE
public static final int HASH_BYTE_SIZE- See Also:
-
PBKDF2_ITERATIONS
public static final int PBKDF2_ITERATIONS- See Also:
-
ITERATION_INDEX
public static final int ITERATION_INDEX- See Also:
-
SALT_INDEX
public static final int SALT_INDEX- See Also:
-
PBKDF2_INDEX
public static final int PBKDF2_INDEX- See Also:
-
-
Constructor Details
-
PasswordHash
public PasswordHash()
-
-
Method Details
-
createHash
public static String createHash(String password) throws NoSuchAlgorithmException, InvalidKeySpecException Returns a salted PBKDF2 hash of the password.- Parameters:
password- the password to hash- Returns:
- a salted PBKDF2 hash of the password
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
createHash
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException Returns a salted PBKDF2 hash of the password.- Parameters:
password- the password to hash- Returns:
- a salted PBKDF2 hash of the password
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
createHash
public static String createHash(char[] password, int iterations) throws NoSuchAlgorithmException, InvalidKeySpecException -
validatePassword
public static boolean validatePassword(String password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException Validates a password using a hash.- Parameters:
password- the password to checkcorrectHash- the hash of the valid password- Returns:
- true if the password is correct, false if not
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
validatePassword
public static boolean validatePassword(char[] password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException Validates a password using a hash.- Parameters:
password- the password to checkcorrectHash- the hash of the valid password- Returns:
- true if the password is correct, false if not
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-