public class PBEKey
extends java.lang.Object
implements javax.crypto.SecretKey
Password based encryption as defined in PKCS#5 encrypts the given message with the DES algorithm in CBC mode using a secret key which is derived from a password with the MD5 message digest algorithm. PKCS#5 recommends, that the password should consist of printable ASCII characters.
This class uses UTF8 for encoding the password. For password consisting of ASCII characters only this will give the default ASCII encoding.
E.g.: "Beavis" gives the following string of 6 bytes:
0x42 0x65 0x61 0x76 0x69 0x73
Constructor and Description |
---|
PBEKey(char[] password)
Creates a new PBEKey from a char array.
|
PBEKey(javax.crypto.spec.PBEKeySpec keySpec)
Creates a new PBEKey from a PBEKeySpec.
|
PBEKey(java.lang.String password)
Creates a new PBEKey from a String.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAlgorithm()
Returns the algorithm name.
|
byte[] |
getEncoded()
Returns the password as byte array.
|
java.lang.String |
getFormat()
Returns the format name.
|
char[] |
getKey()
Returns the password as char array.
|
void |
setAlgorithm(java.lang.String algorithm)
Sets the algorithm name.
|
public PBEKey(java.lang.String password)
password
- the password as a Stringpublic PBEKey(javax.crypto.spec.PBEKeySpec keySpec)
keySpec
- the password as KeySpecpublic PBEKey(char[] password)
password
- the password as a char arraypublic byte[] getEncoded()
getEncoded
in interface java.security.Key
public char[] getKey()
public void setAlgorithm(java.lang.String algorithm)
algorithm
- the algorithm namepublic java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
public java.lang.String getFormat()
getFormat
in interface java.security.Key