<!--
{
  "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/AES/GCM/Nonce",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Apple CryptoKit",
      "CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit3AESO3GCMO5NonceV"
  },
  "title" : "AES.GCM.Nonce"
}
-->

# AES.GCM.Nonce

A value used once during a cryptographic operation and then discarded.

```
struct Nonce
```

## Overview

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.

## Topics

### Creating a nonce

[`init()`](/documentation/CryptoKit/AES/GCM/Nonce/init())

Creates a new random nonce.

[`init<D>(data: D) throws`](/documentation/CryptoKit/AES/GCM/Nonce/init(data:))

Creates a nonce from the given data.

### Iterating over a nonce’s bytes

[`func makeIterator() -> Array<UInt8>.Iterator`](/documentation/CryptoKit/AES/GCM/Nonce/makeIterator())

Returns an iterator over the elements of the nonce.

### Accessing underlying storage

### Initializers

[`init(copying: RawSpan) throws`](/documentation/CryptoKit/AES/GCM/Nonce/init(copying:))

Creates a nonce from the given data.

### Instance Properties

[`var bytes: RawSpan`](/documentation/CryptoKit/AES/GCM/Nonce/bytes)

The bytes stored in the nonce.

[`var count: Int`](/documentation/CryptoKit/AES/GCM/Nonce/count)

The number of bytes stored in the nonce.

## Relationships

### Conforms To

[`ContiguousBytes`](/documentation/Foundation/ContiguousBytes)

[`Sequence`](/documentation/Swift/Sequence)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)