<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/AES/GCM/Nonce/init(copying:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit3AESO3GCMO5NonceV7copyingAGs7RawSpanV_tKcfc"
  },
  "title" : "init(copying:)"
}
-->

# init(copying:)

Creates a nonce from the given data.

```
init(copying bytes: RawSpan) throws
```

## Parameters

`bytes`

The bytes that represent the nonce.
The initializer throws an error if the data has a length smaller than 12 bytes.

## Discussion

Unless your use case calls for a nonce with a specific value, use the
[`init()`](/documentation/CryptoKit/AES/GCM/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)