public class

DESKeySpec

extends Object
implements KeySpec
java.lang.Object
   ↳ javax.crypto.spec.DESKeySpec

Class Overview

The key specification for a DES key.

Summary

Constants
int DES_KEY_LEN The length of a DES key in bytes.
Public Constructors
DESKeySpec(byte[] key)
Creates a new DESKeySpec from the first 8 bytes of the specified key data.
DESKeySpec(byte[] key, int offset)
Creates a new DESKeySpec from the first 8 bytes of the specified key data starting at offset.
Public Methods
byte[] getKey()
Returns a copy of the key.
static boolean isParityAdjusted(byte[] key, int offset)
Returns whether the specified key data starting at offset is parity-adjusted.
static boolean isWeak(byte[] key, int offset)
Returns whether the specified key data starting at offset is weak or semi-weak.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DES_KEY_LEN

Since: API Level 1

The length of a DES key in bytes.

Constant Value: 8 (0x00000008)

Public Constructors

public DESKeySpec (byte[] key)

Since: API Level 1

Creates a new DESKeySpec from the first 8 bytes of the specified key data.

Parameters
key the key data.
Throws
InvalidKeyException if the length of the specified key data is less than 8.

public DESKeySpec (byte[] key, int offset)

Since: API Level 1

Creates a new DESKeySpec from the first 8 bytes of the specified key data starting at offset.

Parameters
key the key data
offset the offset to start at.
Throws
InvalidKeyException if the length of the specified key data starting at offset is less than 8.

Public Methods

public byte[] getKey ()

Since: API Level 1

Returns a copy of the key.

Returns
  • a copy of the key.

public static boolean isParityAdjusted (byte[] key, int offset)

Since: API Level 1

Returns whether the specified key data starting at offset is parity-adjusted.

Parameters
key the key data.
offset the offset to start checking at.
Returns
  • true if the specified key data is parity-adjusted, false otherwise.
Throws
InvalidKeyException if the length of the key data starting at offset is less than 8, or the key is null.

public static boolean isWeak (byte[] key, int offset)

Since: API Level 1

Returns whether the specified key data starting at offset is weak or semi-weak.

Parameters
key the key data.
offset the offset to start checking at.
Returns
  • true if the specified key data is weak or semi-weak.
Throws
InvalidKeyException if the length of the key data starting at offset is less than 8, or it is null.