public abstract class AbsKeyFactory extends java.lang.Object implements KeyFactory
Abstract KeyFactory
implementation for creating secure keys.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ITERATION_COUNT |
static byte[] |
DEFAULT_SALT |
AES, DES
Constructor and Description |
---|
AbsKeyFactory(java.lang.String algorithm,
int maximumKeyLength) |
AbsKeyFactory(java.lang.String algorithm,
int maximumKeyLength,
byte[] salt,
int iterationCount) |
Modifier and Type | Method and Description |
---|---|
java.security.Key |
keyFromPassword(char[] password)
Derives and returns a strong key from a password.
|
java.security.Key |
randomKey()
Generates a strong random key.
|
java.security.Key |
randomKey(int size)
Generates a random key of size
size . |
void |
setIterationCount(int iterationCount)
Sets the amount of hashing iterations to be used by this factory.
|
void |
setSalt(byte[] salt)
Sets the salt to be used by this factory.
|
public static final byte[] DEFAULT_SALT
public static final int DEFAULT_ITERATION_COUNT
public AbsKeyFactory(java.lang.String algorithm, int maximumKeyLength)
algorithm
- maximumKeyLength
- public AbsKeyFactory(java.lang.String algorithm, int maximumKeyLength, byte[] salt, int iterationCount)
algorithm
- maximumKeyLength
- salt
- iterationCount
- public void setSalt(byte[] salt)
Sets the salt to be used by this factory.
salt
- public void setIterationCount(int iterationCount)
Sets the amount of hashing iterations to be used by this factory.
iterationCount
- public final java.security.Key keyFromPassword(char[] password)
KeyFactory
Derives and returns a strong key from a password.
keyFromPassword
in interface KeyFactory
public final java.security.Key randomKey()
KeyFactory
Generates a strong random key.
randomKey
in interface KeyFactory
public final java.security.Key randomKey(int size)
KeyFactory
Generates a random key of size size
.
randomKey
in interface KeyFactory