<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/ChaChaPoly/Nonce/init(data:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit03ChaC4PolyO5NonceV4dataAEx_tKc10Foundation12DataProtocolRzlufc"
  },
  "title" : "init(data:)"
}
-->

# init(data:)

Creates a nonce from the given data.

```
init<D>(data: D) throws where D : DataProtocol
```

## Parameters

`data`

A 12-byte data representation of the nonce.
The initializer throws an error if the data isn’t 12 bytes long.

## Discussion

Unless your use case calls for a nonce with a specific value, use the
[`init()`](/documentation/CryptoKit/ChaChaPoly/Nonce/init()) method to instead create a random nonce.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)