Name
SecretKeySpec
Synopsis
This
class is a transparent and algorithm-independent representation of a
secret key. This class is useful only for encryption algorithms (such
as DES and DESede) whose secret keys can be represented as arbitrary
byte arrays and do not require auxiliary parameters. Note that
SecretKeySpec
implements the
javax.crypto.SecretKey
interface directly, so no
algorithm-specific javax.crypto.SecretKeyFactory
object is required.
Figure 17-27. javax.crypto.spec.SecretKeySpec
public class SecretKeySpec implements java.security.spec.KeySpec, javax.crypto.SecretKey { // Public Constructors public SecretKeySpec(byte[ ] key, String algorithm); public SecretKeySpec(byte[ ] key, int offset, int len, String algorithm); // Methods Implementing Key public String getAlgorithm( ); public byte[ ] getEncoded( ); public String getFormat( ); // Public Methods Overriding Object public boolean equals(Object obj); public int hashCode( ); }
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.