---
title: mainKey
framework: applearchive
role: symbol
role_heading: Instance Property
path: applearchive/archiveencryptioncontext/mainkey
---

# mainKey

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

## Declaration

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

## Discussion

Discussion Use the main key to append data to an existing AEA archive with the 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.

## See Also

### Setting and retrieving keys

- [symmetricKey](applearchive/archiveencryptioncontext/symmetrickey.md)
- [generateSymmetricKey()](applearchive/archiveencryptioncontext/generatesymmetrickey().md)
- [setSymmetricKey(_:)](applearchive/archiveencryptioncontext/setsymmetrickey(_:).md)
- [setRecipientPrivateKey(_:)](applearchive/archiveencryptioncontext/setrecipientprivatekey(_:).md)
- [setSigningPrivateKey(_:)](applearchive/archiveencryptioncontext/setsigningprivatekey(_:).md)
- [setRecipientPublicKey(_:)](applearchive/archiveencryptioncontext/setrecipientpublickey(_:).md)
- [setSigningPublicKey(_:)](applearchive/archiveencryptioncontext/setsigningpublickey(_:).md)
