# SecretKey

public interface **SecretKey** implements [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) [Destroyable](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html)

|---|---|---|
| Known Indirect Subclasses [PBEKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/interfaces/PBEKey.html), [SecretKeySpec](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/SecretKeySpec.html) |---|---| | [PBEKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/interfaces/PBEKey.html) | The interface to a PBE key. | | [SecretKeySpec](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/SecretKeySpec.html) | This class specifies a secret key in a provider-independent fashion. | |||

A secret (symmetric) key.
The purpose of this interface is to group (and provide type safety
for) all secret key interfaces.


Provider implementations of this interface must overwrite the
`equals` and `hashCode` methods inherited from
`https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html`, so that secret keys are compared based on
their underlying key material and not based on reference.
Implementations should override the default `destroy` and
`isDestroyed` methods from the
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html` interface to enable
sensitive key information to be destroyed, cleared, or in the case
where such information is immutable, unreferenced.
Finally, since `SecretKey` is `Serializable`, implementations
should also override
`https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectOutputStream.html#writeObject(java.lang.Object)`
to prevent keys that have been destroyed from being serialized.

Keys that implement this interface return the string `RAW`
as their encoding format (see `getFormat`), and return the
raw key bytes as the result of a `getEncoded` method call. (The
`getFormat` and `getEncoded` methods are inherited
from the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html` parent interface.)

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKeyFactory.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/Cipher.html`

### Constant Summary

|---|---|---|
| long | [serialVersionUID](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html#serialVersionUID) | The class fingerprint that is set to indicate serialization compatibility since J2SE 1.4. |

### Inherited Constant Summary

From interface [java.security.Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html)

|---|---|---|
| long | [serialVersionUID](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html#serialVersionUID) | The class fingerprint that is set to indicate serialization compatibility with a previous version of the class. |

### Inherited Method Summary

From interface [java.security.Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html)

|---|---|
| abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getAlgorithm](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html#getAlgorithm())() Returns the standard algorithm name for this key. |
| abstract byte\[\] | [getEncoded](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html#getEncoded())() Returns the key in its primary encoding format, or null if this key does not support encoding. |
| abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getFormat](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html#getFormat())() Returns the name of the primary encoding format of this key, or null if this key does not support encoding. |

From interface [javax.security.auth.Destroyable](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html)

|---|---|
| void | [destroy](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html#destroy())() Destroy this `Object`. |
| boolean | [isDestroyed](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html#isDestroyed())() Determine if this `Object` has been destroyed. |

## Constants

#### public static final long
**serialVersionUID**

The class fingerprint that is set to indicate serialization
compatibility since J2SE 1.4.
Constant Value: -4795878709595146952