For the latest news and information visit The GNU Crypto project

## gnu.crypto.key
Class GnuSecretKey

    java.lang.Object
      |
      +--gnu.crypto.key.GnuSecretKey

All Implemented Interfaces:
  java.security.Key, java.io.Serializable

public class GnuSecretKey
extends java.lang.Object
implements java.security.Key

A secret key composed of a sequence of raw, unformatted octets. This class is analogous to the `SecretKeySpec` class, but is provided for platforms that do not or cannot contain that class.

See Also:
  Serialized Form

Field Summary

Fields inherited from interface java.security.Key
`serialVersionUID`

Constructor Summary
`GnuSecretKey(byte[] key, int offset, int length, java.lang.String algorithm)` Creates a new secret key from a portion of a byte array.
`GnuSecretKey(byte[] key, java.lang.String algorithm)` Creates a new secret key.

Method Summary
`boolean` `equals(java.lang.Object o)`
`java.lang.String` `getAlgorithm()` Returns the algorithm name, if any.
`byte[]` `getEncoded()` Returns the encoded key, which is merely the byte array this class was created with.
`java.lang.String` `getFormat()` Returns the string "RAW".
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### GnuSecretKey

    public GnuSecretKey(byte[] key,
                        java.lang.String algorithm)

  Creates a new secret key. The supplied byte array is copied by this constructor.

Parameters:
  `key` - The raw, secret key.
  `algorithm` - The algorithm name, which can be null or empty.

### GnuSecretKey

    public GnuSecretKey(byte[] key,
                        int offset,
                        int length,
                        java.lang.String algorithm)

  Creates a new secret key from a portion of a byte array.

Parameters:
  `key` - The raw, secret key.
  `offset` - The offset at which the key begins.
  `length` - The number of bytes that comprise the key.
  `algorithm` - The algorithm name, which can be null or empty.

Method Detail

### getAlgorithm

    public java.lang.String getAlgorithm()

  Returns the algorithm name, if any.

  Specified by:
    `getAlgorithm` in interface `java.security.Key`
  Returns:
    The algorithm name.

### getEncoded

    public byte[] getEncoded()

  Returns the encoded key, which is merely the byte array this class was created with. A reference to the internal byte array is returned, so the caller can delete this key from memory by modifying the returned array.

  Specified by:
    `getEncoded` in interface `java.security.Key`
  Returns:
    The raw key.

### getFormat

    public java.lang.String getFormat()

  Returns the string "RAW".

  Specified by:
    `getFormat` in interface `java.security.Key`
  Returns:
    The string "RAW".

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

For the latest news and information visit The GNU Crypto project

Copyright © 2001, 2002, 2003, 2004 Free Software Foundation, Inc.