SecretKey (Java SE 9 & JDK 9 ) (original) (raw)


public interface SecretKey
extends Key, Destroyable
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 theequals and hashCode methods inherited fromObject, so that secret keys are compared based on their underlying key material and not based on reference. Implementations should override the default destroy andisDestroyed methods from theDestroyable 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 overrideObjectOutputStream.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. (ThegetFormat and getEncoded methods are inherited from the Key parent interface.)
Since:
1.4
See Also:
SecretKeyFactory, Cipher

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.