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)
KeyFactoryDerives and returns a strong key from a password.
keyFromPassword in interface KeyFactorypublic final java.security.Key randomKey()
KeyFactoryGenerates a strong random key.
randomKey in interface KeyFactorypublic final java.security.Key randomKey(int size)
KeyFactoryGenerates a random key of size size.
randomKey in interface KeyFactory