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
Modifier and TypeFieldDescriptionstatic final int
static final int
static final String
static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
createHash
(char[] password) Returns a salted PBKDF2 hash of the password.static String
createHash
(char[] password, int iterations) static String
createHash
(String password) Returns a salted PBKDF2 hash of the password.static boolean
validatePassword
(char[] password, String correctHash) Validates a password using a hash.static boolean
validatePassword
(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:
NoSuchAlgorithmException
InvalidKeySpecException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-