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 void |
main(String[] args)
Tests the basic functionality of the PasswordHash class
|
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 hashNoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException
password - the password to hashNoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static boolean validatePassword(String password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException
password - the password to checkcorrectHash - the hash of the valid passwordNoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static boolean validatePassword(char[] password,
String correctHash)
throws NoSuchAlgorithmException,
InvalidKeySpecException
password - the password to checkcorrectHash - the hash of the valid passwordNoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static void main(String[] args)
args - ignoredCopyright © 2014–2015. All rights reserved.