<!--
{
  "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/sign(encryptedStream:encryptionContext:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple Archive",
      "AppleArchive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B17EncryptionContextC4sign15encryptedStream010encryptionD0yAA0b4ByteG0C_ACtKFZ"
  },
  "title" : "sign(encryptedStream:encryptionContext:)"
}
-->

# sign(encryptedStream:encryptionContext:)

Signs an encrypted archive using the credentials stored in the specified encryption context.

```
static func sign(encryptedStream: ArchiveByteStream, encryptionContext context: ArchiveEncryptionContext) throws
```

## Parameters

`encryptedStream`

A read-write byte stream that points to an encrypted archive.

`context`

The encryption context that provides the credentials.

## Discussion

Close the encrypted stream before calling this function, and create the archive with a `signatureMode` other than [`none`](/documentation/AppleArchive/ArchiveEncryptionContext/SignatureMode-swift.struct/none). Create the context that you pass to this function from the same archive and it must contain the signature encryption key and the signing private key.

---

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)