Class SCryptPassword.Encoder
- All Implemented Interfaces:
Password.Encoder<SCryptPassword,
SCryptPassword.Encoder>
- Enclosing class:
SCryptPassword
A Scrypt password encoder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default block size factor:8
.static final int
The default cost factor as power of two:2^14
.static final int
The default hash length in kikibytes:32
.static final int
The default parallelization factor:1
.static final int
The default salt length in kikibytes:16
. -
Constructor Summary
ConstructorDescriptionEncoder()
Creates a default Scrypt password encoder.Encoder
(int saltLength, int costFactor, int blockSizeFactor, int parallelizationFactor, int hashLength) Creates a default Scrypt password encoder with the specified salt length, cost factor, block size factor, parallelization factor and hash length.Encoder
(int saltLength, int costFactor, int blockSizeFactor, int parallelizationFactor, int hashLength, SecureRandom secureRandom) Creates a default Scrypt password encoder with the specified salt length, cost factor, block size factor, parallelization factor, hash length and secure random. -
Method Summary
Modifier and TypeMethodDescriptionEncodes the specified raw password.boolean
int
Returns the block size factor.int
Returns the cost factor.int
Returns the hash length in kikibytes.int
Returns the parallelization factor.int
Returns the salt length in kikibytes.Returns the secure random.int
hashCode()
boolean
Matches the specified raw password with the specified encoded representation.Recovers a password from its encoded representation generated with this encoder.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.security.authentication.password.Password.Encoder
matches
-
Field Details
-
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTHThe default salt length in kikibytes:16
.- See Also:
-
DEFAULT_COST_FACTOR
public static final int DEFAULT_COST_FACTORThe default cost factor as power of two:2^14
.- See Also:
-
DEFAULT_BLOCK_SIZE_FACTOR
public static final int DEFAULT_BLOCK_SIZE_FACTORThe default block size factor:8
.- See Also:
-
DEFAULT_PARALLELIZATION_FACTOR
public static final int DEFAULT_PARALLELIZATION_FACTORThe default parallelization factor:1
.- See Also:
-
DEFAULT_HASH_LENGTH
public static final int DEFAULT_HASH_LENGTHThe default hash length in kikibytes:32
.- See Also:
-
-
Constructor Details
-
Encoder
public Encoder()Creates a default Scrypt password encoder.
-
Encoder
public Encoder(int saltLength, int costFactor, int blockSizeFactor, int parallelizationFactor, int hashLength) throws IllegalArgumentException Creates a default Scrypt password encoder with the specified salt length, cost factor, block size factor, parallelization factor and hash length.
- Parameters:
saltLength
- the salt length in kikibytescostFactor
- the cost factorblockSizeFactor
- the block size factorparallelizationFactor
- the parallelization factorhashLength
- the hash length in kikibytes- Throws:
IllegalArgumentException
- if specified parameters are incorrect
-
Encoder
public Encoder(int saltLength, int costFactor, int blockSizeFactor, int parallelizationFactor, int hashLength, SecureRandom secureRandom) throws IllegalArgumentException Creates a default Scrypt password encoder with the specified salt length, cost factor, block size factor, parallelization factor, hash length and secure random.
- Parameters:
saltLength
- the salt length in kikibytescostFactor
- the cost factorblockSizeFactor
- the block size factorparallelizationFactor
- the parallelization factorhashLength
- the hash length in kikibytessecureRandom
- the secure random- Throws:
IllegalArgumentException
- if specified parameters are incorrect
-
-
Method Details
-
getSaltLength
public int getSaltLength()Returns the salt length in kikibytes.
- Returns:
- the salt length
-
getCostFactor
public int getCostFactor()Returns the cost factor.
- Returns:
- the cost factor.
-
getBlockSizeFactor
public int getBlockSizeFactor()Returns the block size factor.
- Returns:
- the block size factor
-
getParallelizationFactor
public int getParallelizationFactor()Returns the parallelization factor.
- Returns:
- the parallelization factor
-
getHashLength
public int getHashLength()Returns the hash length in kikibytes.
- Returns:
- the hash length
-
getSecureRandom
Returns the secure random.
- Returns:
- the secure random
-
recover
Description copied from interface:Password.Encoder
Recovers a password from its encoded representation generated with this encoder.
- Specified by:
recover
in interfacePassword.Encoder<SCryptPassword,
SCryptPassword.Encoder> - Parameters:
encoded
- an encoded password representation- Returns:
- a password
- Throws:
PasswordException
- if there was an error recovering the password or if the specified encoded representation was not generated with this encoder
-
encode
Description copied from interface:Password.Encoder
Encodes the specified raw password.
- Specified by:
encode
in interfacePassword.Encoder<SCryptPassword,
SCryptPassword.Encoder> - Parameters:
raw
- a raw password- Returns:
- an encoded password
- Throws:
PasswordException
- if there was an error encoding the password
-
matches
Description copied from interface:Password.Encoder
Matches the specified raw password with the specified encoded representation.
- Specified by:
matches
in interfacePassword.Encoder<SCryptPassword,
SCryptPassword.Encoder> - Parameters:
raw
- a raw passwordencoded
- an encoded password- Returns:
- true if passwords match, false otherwise
- Throws:
PasswordException
- if there was an error matching passwords
-
hashCode
public int hashCode() -
equals
-