<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HPKE/Sender/exportSecret(context:outputByteCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4HPKEO6SenderV12exportSecret7context15outputByteCountAA12SymmetricKeyVx_SitK10Foundation12DataProtocolRzlF"
  },
  "title" : "exportSecret(context:outputByteCount:)"
}
-->

# exportSecret(context:outputByteCount:)

Exports a secret given domain-separation context and the desired output length.

```
func exportSecret<Context>(context: Context, outputByteCount: Int) throws -> SymmetricKey where Context : DataProtocol
```

## Parameters

`context`

Application-specific information providing context on the use of this key.

`outputByteCount`

The desired length of the exported secret.

## Return Value

The exported secret.

---

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)