public final class CredentialsHasher extends Object
Modifier and Type | Field and Description |
---|---|
static String[] |
ALGS_NAMES
Names of the algorithms used by default.
|
static Integer |
MAX_MAX_CYCLES
The maximum for the maximum number of hash cycles.
|
static Integer |
MIN_MIN_CYCLES
The minimum for the minimum number of hash cycles.
|
Constructor and Description |
---|
CredentialsHasher()
Public constructor.
|
CredentialsHasher(HashedCredentials hashedCredentials)
Public constructor.
|
CredentialsHasher(String[] algorithmsNames,
Integer minCycles,
Integer maxCycles)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
Integer |
getAlgorithmPrime()
Gets the prime to be used in the algorithm selection.
|
MessageDigest[] |
getAlgorithms()
Gets the algorithms to be used in the hash calculation.
|
Integer |
getCyclePrime()
Gets the prime to be used in the cycle selection.
|
Integer |
getMaxCycles()
Gets the maximum number of hash cycles to be used in the hash calculation.
|
Integer |
getMinCycles()
Gets the minimum number of hash cycles to be used in the hash calculation.
|
byte[] |
hash(byte[] credentials,
String salt)
Gets the hash from a given credential.
|
byte[] |
hash(String credentials,
String salt)
Gets the hash from a given credentials.
|
void |
setAlgorithmPrime(Integer algorithmPrime)
Sets the prime to be used in the algorithm selection.
|
void |
setAlgorithms(String[] algorithmsNames)
Sets the algorithms (with the given names) to be used in the hash calculation.
|
void |
setCredentialHasher(HashedCredentials hashedCredentials)
Sets the credential hasher with basic information on hash calculation.
|
void |
setCredentialHasher(String[] algorithmsNames,
Integer minCycles,
Integer maxCycles)
Sets the credential hasher with basic information on hash calculation.
|
void |
setCyclePrime(Integer cyclePrime)
Sets the prime to be used in the cycle selection.
|
void |
setMaxCycles(Integer maxCycles)
Sets the maximum number of hash cycles to be used in the hash calculation.
|
void |
setMinCycles(Integer minCycles)
Sets the minimum number of hash cycles to be used in the hash calculation.
|
public static final String[] ALGS_NAMES
public static final Integer MIN_MIN_CYCLES
public static final Integer MAX_MAX_CYCLES
public CredentialsHasher()
public CredentialsHasher(String[] algorithmsNames, Integer minCycles, Integer maxCycles)
algorithmsNames
- Names of the algorithms to be used in the hash calculation. The first algorithm is also used
in other calculations.minCycles
- The minimum number of hash cycles to be used in the hash calculation.maxCycles
- The maximum number of hash cycles to be used in the hash calculation.public CredentialsHasher(HashedCredentials hashedCredentials)
hashedCredentials
- A credential containing information on how to be hashed.public MessageDigest[] getAlgorithms()
public void setAlgorithms(String[] algorithmsNames)
algorithmsNames
- Names of the algorithms to be used in the hash calculation. The first algorithm is also used
in other calculations.public Integer getMinCycles()
public void setMinCycles(Integer minCycles)
minCycles
- New minimum number of hash cycles to be used in the hash calculation.public Integer getMaxCycles()
public void setMaxCycles(Integer maxCycles)
maxCycles
- New maximum number of hash cycles to be used in the hash calculation.public Integer getAlgorithmPrime()
public void setAlgorithmPrime(Integer algorithmPrime)
algorithmPrime
- New prime to be used in the algorithm selection.public Integer getCyclePrime()
public void setCyclePrime(Integer cyclePrime)
cyclePrime
- New prime to be used in the cycle selection.public void setCredentialHasher(String[] algorithmsNames, Integer minCycles, Integer maxCycles)
algorithmsNames
- Names of the algorithms to be used in the hash calculation. The first algorithm is also used
in other calculations.minCycles
- The minimum number of hash cycles to be used in the hash calculation.maxCycles
- The maximum number of hash cycles to be used in the hash calculation.public void setCredentialHasher(HashedCredentials hashedCredentials)
hashedCredentials
- A credential containing information on how to be hashed.public byte[] hash(byte[] credentials, String salt)
credentials
- The credential to be hashed.salt
- Salt to be used in the hash calculation. It is a good idea to have an unique salt per user.Copyright © 2013. All Rights Reserved.