public class SecretKey
extends javax.crypto.spec.SecretKeySpec
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.
|
boolean |
equals(java.lang.Object obj)
Compares two secret keys.
|
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.
|
int |
hashCode()
Returns a hash code value for this object.
|
void |
setAlgorithm(java.lang.String algorithm)
Sets the algorithm name of this secret key.
|
java.lang.String |
toString()
Returns a string representation of this SecretKey.
|
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 void setAlgorithm(java.lang.String algorithm)
algorithm - the name of the algorithm for this keypublic java.lang.String getFormat()
getFormat in interface java.security.KeygetFormat in class javax.crypto.spec.SecretKeySpecpublic void destroyCriticalData()
public boolean equals(java.lang.Object obj)
equals in class javax.crypto.spec.SecretKeySpecobj - an object to be compared with this pointpublic int hashCode()
hashCode in class javax.crypto.spec.SecretKeySpecpublic java.lang.String toString()
toString in class java.lang.Object