---
title: SymmetricKey
framework: cryptokit
role: symbol
role_heading: Structure
path: cryptokit/symmetrickey
---

# SymmetricKey

A symmetric cryptographic key.

## Declaration

```swift
struct SymmetricKey
```

## Overview

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

## Topics

### Creating a key

- [init(data:)](cryptokit/symmetrickey/init(data:).md)
- [init(size:)](cryptokit/symmetrickey/init(size:).md)

### Getting the key length

- [bitCount](cryptokit/symmetrickey/bitcount.md)

### Initializers

- [init(copying:)](cryptokit/symmetrickey/init(copying:).md)
- [init(copyingWithZeroing:)](cryptokit/symmetrickey/init(copyingwithzeroing:).md)
- [init(size:initializingWith:)](cryptokit/symmetrickey/init(size:initializingwith:).md)

### Instance Properties

- [bytes](cryptokit/symmetrickey/bytes.md)

## Relationships

### Conforms To

- [ContiguousBytes](foundation/contiguousbytes.md)
- [Equatable](swift/equatable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Message authentication codes

- [HMAC](cryptokit/hmac.md)
- [SymmetricKeySize](cryptokit/symmetrickeysize.md)
