<!--
{
  "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/mainKey",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Apple Archive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B17EncryptionContextC7mainKey9CryptoKit09SymmetricF0VSgvp"
  },
  "title" : "mainKey"
}
-->

# mainKey

The main key used to append data to an existing archive.

```
var mainKey: SymmetricKey? { get set }
```

## Discussion

Use the main key to append data to an existing AEA archive with the [`encryptionStream(appendingTo:encryptionContext:flags:threadCount:)`](/documentation/AppleArchive/ArchiveByteStream/encryptionStream(appendingTo:encryptionContext:flags:threadCount:)) function.

You can use the original credentials for symmetric key or password encryption. You need this key to reopen archives created with the ECDHE profiles.

The main key can’t be used to open the stream for decryption.

---

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)