public class SecretKey
extends javax.crypto.spec.SecretKeySpec
implements java.io.Serializable
SecretKey,
Key,
KeyGenerator,
Serialized Form| Constructor and Description |
|---|
SecretKey(byte[] key,
int off,
int len,
java.lang.String algName)
Creates a SecretKey object from given byte sub-array and algorithm name.
|
SecretKey(byte[] key,
java.lang.String algName)
Creates a SecretKey object from given byte array and algorithm name.
|
SecretKey(javax.crypto.SecretKey key) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroyCriticalData()
Destroys the critical data of this object.
|
java.lang.String |
getAlgorithm()
Returns the name of the key algorithm for this key.
|
byte[] |
getEncoded()
Returns a copy of the secret key as byte array.
|
java.lang.String |
getFormat()
Returns the format name.
|
java.lang.String |
toString() |
public SecretKey(byte[] key,
java.lang.String algName)
This constructor is called from inside a KeyGenerator to create a SecretKey.
Applications shall use the KeyGenerator.getInstance
and generateKey methods for creating a SecretKey object.
key - the key as byte arrayalgName - the name of the key algorithmKeyGenerator.getInstance(java.lang.String),
KeyGenerator.generateKey()public SecretKey(byte[] key,
int off,
int len,
java.lang.String algName)
off, only len bytes of the given key
byte array are used for creating the SecretKey.
This constructor is called from inside a KeyGenerator to create a SecretKey.
Applications shall use the KeyGenerator.getInstance
and generateKey methods for creating a SecretKey object.
key - the key as byte arrayalgName - the name of the key algorithmKeyGenerator.getInstance(java.lang.String),
KeyGenerator.generateKey()public SecretKey(javax.crypto.SecretKey key)
throws java.security.InvalidKeyException
java.security.InvalidKeyExceptionpublic byte[] getEncoded()
getEncoded in interface java.security.KeygetEncoded in class javax.crypto.spec.SecretKeySpecpublic java.lang.String getAlgorithm()
getAlgorithm in interface java.security.KeygetAlgorithm in class javax.crypto.spec.SecretKeySpecpublic java.lang.String getFormat()
getFormat in interface java.security.KeygetFormat in class javax.crypto.spec.SecretKeySpecpublic void destroyCriticalData()
public java.lang.String toString()
toString in class java.lang.Object