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(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.
|
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
InvalidKeySpecException
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException
password
- the password to hashNoSuchAlgorithmException
InvalidKeySpecException
public static String createHash(char[] password, int iterations) throws NoSuchAlgorithmException, InvalidKeySpecException
public static boolean validatePassword(String password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException
password
- the password to checkcorrectHash
- the hash of the valid passwordNoSuchAlgorithmException
InvalidKeySpecException
public static boolean validatePassword(char[] password, String correctHash) throws NoSuchAlgorithmException, InvalidKeySpecException
password
- the password to checkcorrectHash
- the hash of the valid passwordNoSuchAlgorithmException
InvalidKeySpecException
Copyright © 2023 Frank!Framework. All rights reserved.