crypto / org.apache.tuweni.crypto.sodium / SecretBox / Nonce

Nonce

class Nonce : Destroyable (source)

A SecretBox nonce.

Functions

bytes

fun bytes(): Bytes

bytesArray

fun bytesArray(): ByteArray

destroy

fun destroy(): Unit

equals

fun equals(other: Any?): Boolean

fromBytes

static fun fromBytes(bytes: Bytes): Nonce
static fun fromBytes(bytes: ByteArray): Nonce

Create a Nonce from an array of bytes.

The byte array must be of length #length().

hashCode

fun hashCode(): Int

increment

fun increment(): Nonce

Increment this nonce.

Note that this is not synchronized. If multiple threads are creating encrypted messages and incrementing this nonce, then external synchronization is required to ensure no two encrypt operations use the same nonce.

length

static fun length(): Int

Obtain the length of the nonce in bytes (24).

random

static fun random(): Nonce

Generate a random Nonce.

zero

static fun zero(): Nonce

Create a zero Nonce.