Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.crypto.spec.PBEKeySpec
Examples of password-based encryption algorithms include:
SecretKeyFactory
, PBEParameterSpec
Constructor Summary | |
| |
| |
|
Method Summary | |
void |
|
int |
|
int |
|
char[] |
|
byte[] |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public PBEKeySpec(char[] password)
Create a new PBE key spec with just a password.A copy of the password argument is stored instead of the argument itself.
- Parameters:
password
- The password char array.
public PBEKeySpec(char[] password, byte[] salt, int iterationCount)
Create a PBE key spec with a password, salt, and iteration count.A copy of the password and salt arguments are stored instead of the arguments themselves.
- Parameters:
password
- The password char array.salt
- The salt bytes.iterationCount
- The iteration count.
- Throws:
NullPointerException
- If salt is nullIllegalArgumentException
- If salt is an empty array, or iterationCount is negative
public PBEKeySpec(char[] password, byte[] salt, int iterationCount, int keyLength)
Create a PBE key spec with a password, salt, iteration count, and key length.A copy of the password and salt arguments are stored instead of the arguments themselves.
- Parameters:
password
- The password char array.salt
- The salt bytes.iterationCount
- The iteration count.keyLength
- The generated key length.
- Throws:
NullPointerException
- If salt is nullIllegalArgumentException
- If salt is an empty array, if iterationCount or keyLength is negative
public final void clearPassword()
Clear the password array by filling it with null characters.This clears the stored copy of the password, not the original char array used to create the password.
public final int getIterationCount()
Get the iteration count, or 0 if it has not been specified.
- Returns:
- The iteration count, or 0 if it has not been specified.
public final int getKeyLength()
Get the generated key length, or 0 if it has not been specified.
- Returns:
- The key length, or 0 if it has not been specified.
public final char[] getPassword()
Get the password character array copy.This returns a copy of the password, not the password itself.
- Returns:
- a clone of the password.
- Throws:
IllegalStateException
- IfclearPassword()
has already been called.
public final byte[] getSalt()
Get the salt bytes array copy.This returns a copy of the salt, not the salt itself.
- Returns:
- The salt.