<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveEncryptionContext/setSymmetricKey(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Apple Archive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B17EncryptionContextC15setSymmetricKeyyy9CryptoKit0fG0VKF"
  },
  "title" : "setSymmetricKey(_:)"
}
-->

# setSymmetricKey(_:)

Sets the symmetric encryption key that the context requires for symmetric encryption mode.

```
func setSymmetricKey(_ key: SymmetricKey) throws
```

## Parameters

`key`

The symmetric encryption key.

## Discussion

Use this function to set the encryption key for a context with a symmetric [`profile`](/documentation/AppleArchive/ArchiveEncryptionContext/profile-swift.property).

## See Also

  <doc://com.apple.documentation/documentation/CryptoKit/SymmetricKey>



---

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)