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

# SymmetricKey

A symmetric cryptographic key.

```
struct SymmetricKey
```

## Overview

You typically derive a symmetric key from an instance of a shared secret
([`SharedSecret`](/documentation/CryptoKit/SharedSecret)) that you obtain through key agreement. You use a
symmetric key to compute a message authentication code like [`HMAC`](/documentation/CryptoKit/HMAC), or to
open and close a sealed box ([`ChaChaPoly.SealedBox`](/documentation/CryptoKit/ChaChaPoly/SealedBox) or
[`AES.GCM.SealedBox`](/documentation/CryptoKit/AES/GCM/SealedBox)) using a cipher like [`ChaChaPoly`](/documentation/CryptoKit/ChaChaPoly) or [`AES`](/documentation/CryptoKit/AES).

## Topics

### Creating a key

[`init(data:)`](/documentation/CryptoKit/SymmetricKey/init(data:))

Creates a key from the given data.

[`init(size:)`](/documentation/CryptoKit/SymmetricKey/init(size:))

Generates a new random key of the given size.

### Getting the key length

[`bitCount`](/documentation/CryptoKit/SymmetricKey/bitCount)

The number of bits in the key.

### Accessing underlying data



---

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)