public class SecretKeySpec extends Object implements SecretKey, KeySpec, Serializable
SecretKey and also a secret key
implementation that is provider-independent. It can be used for raw secret
keys that can be specified as byte[].| Constructor and Description |
|---|
SecretKeySpec(byte[] key,
int offset,
int len,
String algorithm)
Creates a new
SecretKeySpec for the key data from the
specified buffer key starting at offset with
length len and the specified algorithm name. |
SecretKeySpec(byte[] key,
String algorithm)
Creates a new
SecretKeySpec for the specified key data and
algorithm name. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Compares the specified object with this
SecretKeySpec
instance. |
String |
getAlgorithm()
Returns the algorithm name.
|
byte[] |
getEncoded()
Returns the encoded form of this secret key.
|
String |
getFormat()
Returns the name of the format used to encode the key.
|
int |
hashCode()
Returns the hash code of this
SecretKeySpec object. |
public SecretKeySpec(byte[] key,
String algorithm)
SecretKeySpec for the specified key data and
algorithm name.key - the key data.algorithm - the algorithm name.IllegalArgumentException - if the key data or the algorithm name is null or if the key
data is empty.public SecretKeySpec(byte[] key,
int offset,
int len,
String algorithm)
SecretKeySpec for the key data from the
specified buffer key starting at offset with
length len and the specified algorithm name.key - the key data.offset - the offset.len - the size of the key data.algorithm - the algorithm name.IllegalArgumentException - if the key data or the algorithm name is null, the key data
is empty or offset and len do not
specify a valid chunk in the buffer key.ArrayIndexOutOfBoundsException - if offset or len is negative.public String getAlgorithm()
getAlgorithm in interface Keypublic String getFormat()
public byte[] getEncoded()
getEncoded in interface Keypublic int hashCode()
SecretKeySpec object.hashCode in class ObjectObject.equals(java.lang.Object)public boolean equals(Object obj)
SecretKeySpec
instance.equals in class Objectobj - the object to compare.Object.hashCode()