One Logo Pool Ball
CryptoKit · IOS API REFERENCE

ChaChaPoly.Nonce

struct · iOS 13.0+ · SDK 27.1

struct Nonce

A value used once during a cryptographic operation and then discarded. Don’t reuse the same nonce for multiple calls to encryption APIs. It’s critical that nonces are unique per call to encryption APIs in order to protect the integrity of the encryption.

Members (5)

method · iOS 13.0+

makeIterator

TypeScript
makeIterator(): SDKHandle
Swift declaration
func makeIterator() -> Array<UInt8>.Iterator

Returns an iterator over the elements of the nonce.

method · iOS 13.0+

withUnsafeBytes

TypeScript
withUnsafeBytes(body: ((arg0: ArrayBuffer) => unknown)): unknown
Swift declaration
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R

Calls the given closure with the contents of underlying storage. - note: Calling `withUnsafeBytes` multiple times does not guarantee that the same buffer pointer will be passed in every time. - warning: The buffer argument to the body should not be stored or used outside of the lifetime of the call to the closure. Clients should prefer the `withBytes` function to this one, because `withBytes` uses the non-escapable type `RawSpan` to ensure that the buffer argument is not stored outside of the closure.

init · iOS 13.0+

init

TypeScript
static initData(data: ArrayBuffer): ChaChaPoly_Nonce
Swift declaration
init<D>(data: D) throws where D : DataProtocol

Creates a nonce from the given data. Unless your use case calls for a nonce with a specific value, use the ``init()`` method to instead create a random nonce. - Parameters: - data: A 12-byte data representation of the nonce. The initializer throws an error if the data isn't 12 bytes long.

get · iOS 13.0+

count

TypeScript
get count(): number
Swift declaration
var count: Int { get }

The number of bytes stored in the nonce.

init · iOS 13.0+

init

TypeScript
static init(): ChaChaPoly_Nonce
Swift declaration
init()

Creates a new random nonce. The default nonce is a 12-byte random nonce.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ChaChaPoly.Nonce.init(copying:)

The iOS SDK compiler rejected this binding: instance method 'arg' requires that 'RawSpan' conform to 'Escapable'

ChaChaPoly.Nonce.bytes

The iOS SDK compiler rejected this binding: argument type 'RawSpan' does not conform to expected type 'Escapable'

All CryptoKit types →