public class PasswordHash extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DERIVED_KEY_SIZE |
static int |
ITERATION_INDEX |
static int |
PBKDF2_INDEX |
static int |
PBKDF2_ITERATIONS |
static int |
SALT_BYTE_SIZE |
static int |
SALT_INDEX |
| Modifier and Type | Method and Description |
|---|---|
static String |
createHash(byte[] password)
Returns a salted PBKDF2 hash of the password.
|
static String |
createHash(byte[] password,
int saltSize,
int iterations,
int dkSize)
Returns a salted PBKDF2 hash of the password.
|
static String |
createHash(String password)
Returns a salted PBKDF2 hash of the password.
|
static byte[] |
pbkdf2(byte[] password,
byte[] salt,
int iterations,
int bytes)
Computes the PBKDF2 hash of a password.
|
static boolean |
validatePassword(byte[] 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 int SALT_BYTE_SIZE
public static final int DERIVED_KEY_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)
password - - the password to hashpublic static String createHash(byte[] password)
password - - the password to hashpublic static String createHash(byte[] password, int saltSize, int iterations, int dkSize)
password - - the password to hashsaltSize - - the size of salt in bytesiterations - - the iteration count (slowness factor)dkSize - - the length of the derived keypublic static boolean validatePassword(String password, String correctHash)
password - - the password to checkcorrectHash - - the hash of the valid passwordpublic static boolean validatePassword(byte[] password,
String correctHash)
password - - the password to checkcorrectHash - - the hash of the valid passwordpublic static byte[] pbkdf2(byte[] password,
byte[] salt,
int iterations,
int bytes)
password - - the password to hash.salt - - the saltiterations - - the iteration count (slowness factor)bytes - - the length of the hash to compute in bytesCopyright © 2018. All rights reserved.