public class PasswordHash
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
HASH_BYTES |
static int |
ITERATION_INDEX |
static java.lang.String |
PBKDF2_ALGORITHM |
static int |
PBKDF2_INDEX |
static int |
PBKDF2_ITERATIONS |
static int |
SALT_BYTES |
static int |
SALT_INDEX |
| Constructor and Description |
|---|
PasswordHash() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
createHash(char[] password)
Returns a salted PBKDF2 hash of the password.
|
static java.lang.String |
createHash(java.lang.String password)
Returns a salted PBKDF2 hash of the password.
|
static boolean |
validatePassword(char[] password,
java.lang.String goodHash)
Validates a password using a hash.
|
static boolean |
validatePassword(java.lang.String password,
java.lang.String goodHash)
Validates a password using a hash.
|
public static final java.lang.String PBKDF2_ALGORITHM
public static final int SALT_BYTES
public static final int HASH_BYTES
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 java.lang.String createHash(java.lang.String password)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
password - the password to hashjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionpublic static java.lang.String createHash(char[] password)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
password - the password to hashjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionpublic static boolean validatePassword(java.lang.String password,
java.lang.String goodHash)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
password - the password to checkgoodHash - the hash of the valid passwordjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecExceptionpublic static boolean validatePassword(char[] password,
java.lang.String goodHash)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
password - the password to checkgoodHash - the hash of the valid passwordjava.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecException