Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#constants) \| [Ctors](https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#pubctors) \| [Methods](https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#inhmethods)

# DESKeySpec


`
public


class
DESKeySpec
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/security/spec/KeySpec


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.crypto.spec.DESKeySpec |

<br />

*** ** * ** ***

This class specifies a DES key.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#DES_KEY_LEN` The constant which defines the length of a DES key in bytes. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#DESKeySpec(byte[])(byte[] key) ` Creates a DESKeySpec object using the first 8 bytes in `key` as the key material for the DES key. |
| ` https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#DESKeySpec(byte[],%20int)(byte[] key, int offset) ` Creates a DESKeySpec object using the first 8 bytes in `key`, beginning at `offset` inclusive, as the key material for the DES key. |

| ### Public methods ||
|---|---|
| ` byte[]` | ` https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#getKey()() ` Returns the DES key material. |
| ` static boolean` | ` https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#isParityAdjusted(byte[],%20int)(byte[] key, int offset) ` Checks if the given DES key material, starting at `offset` inclusive, is parity-adjusted. |
| ` static boolean` | ` https://developer.android.com/reference/javax/crypto/spec/DESKeySpec#isWeak(byte[],%20int)(byte[] key, int offset) ` Checks if the given DES key material is weak or semi-weak. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### DES_KEY_LEN

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DES_KEY_LEN
```

The constant which defines the length of a DES key in bytes.

<br />

Constant Value:

8
(0x00000008)


## Public constructors

### DESKeySpec

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public DESKeySpec (byte[] key)
```

Creates a DESKeySpec object using the first 8 bytes in
`key` as the key material for the DES key.

The bytes that constitute the DES key are those between
`key[0]` and `key[7]` inclusive.

<br />

| Parameters ||
|---|---|
| `key` | `byte`: the buffer with the DES key material. The first 8 bytes of the buffer are copied to protect against subsequent modification. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the given key material is `null` |
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key material is shorter than 8 bytes. |

### DESKeySpec

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public DESKeySpec (byte[] key, 
                int offset)
```

Creates a DESKeySpec object using the first 8 bytes in
`key`, beginning at `offset` inclusive,
as the key material for the DES key.

The bytes that constitute the DES key are those between
`key[offset]` and `key[offset+7]` inclusive.

<br />

| Parameters ||
|---|---|
| `key` | `byte`: the buffer with the DES key material. The first 8 bytes of the buffer beginning at `offset` inclusive are copied to protect against subsequent modification. <br /> |
| `offset` | `int`: the offset in `key`, where the DES key material starts. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the given key material is `null` |
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key material, starting at `offset` inclusive, is shorter than 8 bytes. |

## Public methods

### getKey

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getKey ()
```

Returns the DES key material.

<br />

| Returns ||
|---|---|
| `byte[]` | the DES key material. Returns a new array each time this method is called. <br /> |

### isParityAdjusted

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Checks if the given DES key material, starting at `offset`
inclusive, is parity-adjusted.

<br />

| Parameters ||
|---|---|
| `key` | `byte`: the buffer with the DES key material. <br /> |
| `offset` | `int`: the offset in `key`, where the DES key material starts. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the given DES key material is parity-adjusted, false otherwise. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key material is `null`, or starting at `offset` inclusive, is shorter than 8 bytes. |

### isWeak

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Checks if the given DES key material is weak or semi-weak.

<br />

| Parameters ||
|---|---|
| `key` | `byte`: the buffer with the DES key material. <br /> |
| `offset` | `int`: the offset in `key`, where the DES key material starts. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the given DES key material is weak or semi-weak, false otherwise. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key material is `null`, or starting at `offset` inclusive, is shorter than 8 bytes. |