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

# ChaCha20ParameterSpec

` public final class ChaCha20ParameterSpec `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/security/spec/AlgorithmParameterSpec `

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

<br />

*** ** * ** ***

This class specifies the parameters used with the [*ChaCha20*](https://tools.ietf.org/html/rfc7539) algorithm.

The parameters consist of a 12-byte nonce and an initial counter value expressed as a 32-bit integer.

This class can be used to initialize a `Cipher` object that implements the *ChaCha20* algorithm.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/crypto/spec/ChaCha20ParameterSpec#ChaCha20ParameterSpec(byte[],%20int)(byte[] nonce, int counter) ` Constructs a parameter set for ChaCha20 from the given nonce and counter. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/javax/crypto/spec/ChaCha20ParameterSpec#getCounter()() ` Returns the configured counter value. |
| ` byte[]` | ` https://developer.android.com/reference/javax/crypto/spec/ChaCha20ParameterSpec#getNonce()() ` Returns the nonce value. |

### 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*.

## Public constructors

### ChaCha20ParameterSpec

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

```
public ChaCha20ParameterSpec (byte[] nonce, 
                int counter)
```

Constructs a parameter set for ChaCha20 from the given nonce and counter.

<br />

| Parameters ||
|---|---|
| `nonce` | `byte`: a 12-byte nonce value <br /> |
| `counter` | `int`: the initial counter value <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `nonce` is not 12 bytes in length |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `nonce` is `null` |

## Public methods

### getCounter

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

```
public int getCounter ()
```

Returns the configured counter value.

<br />

| Returns ||
|---|---|
| `int` | the counter value <br /> |

### getNonce

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

```
public byte[] getNonce ()
```

Returns the nonce value.

<br />

| Returns ||
|---|---|
| `byte[]` | the nonce value. This method returns a new array each time this method is called. <br /> |