public class PasswordHash extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
HASH_BYTE_SIZE |
static int |
ITERATION_INDEX |
static String |
PBKDF2_ALGORITHM |
static int |
PBKDF2_INDEX |
static int |
PBKDF2_ITERATIONS |
static int |
SALT_BYTE_SIZE |
static int |
SALT_INDEX |
| Constructor and Description |
|---|
PasswordHash() |
| Modifier and Type | Method and Description |
|---|---|
static String |
createHash(char[] password)
Returns a salted PBKDF2 hash of the password.
|
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.
|
public static final String PBKDF2_ALGORITHM
public static final int SALT_BYTE_SIZE
public static final int HASH_BYTE_SIZE
public static final int PBKDF2_ITERATIONS
public static final int ITERATION_INDEX
public static final int SALT_INDEX
public static final int PBKDF2_INDEX
public static String createHash(String password) throws NoSuchAlgorithmException, InvalidKeySpecException
password - the password to hashNoSuchAlgorithmException - if jdk does not support the algorithmInvalidKeySpecException - if the password or salt are invalidpublic static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException
password - the password to hashNoSuchAlgorithmException - if jdk does not support the algorithmInvalidKeySpecException - if the password or salt are invalidpublic static boolean validatePassword(String password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException
password - the password to checkcorrectHash - the hash of the valid passwordNoSuchAlgorithmException - if jdk does not support the algorithmInvalidKeySpecException - if the password or salt are invalidpublic static boolean validatePassword(char[] password,
String correctHash)
throws NoSuchAlgorithmException,
InvalidKeySpecException
password - the password to checkcorrectHash - the hash of the valid passwordNoSuchAlgorithmException - if jdk does not support the algorithmInvalidKeySpecException - if the password or salt are invalidCopyright © 2016 Inbot. All Rights Reserved.