---
title: encapsulate()
framework: cryptokit
role: symbol
role_heading: Instance Method
path: cryptokit/mlkem1024/publickey/encapsulate()
---

# encapsulate()

Generates and encapsulates a shared secret.

## Declaration

```swift
func encapsulate() throws -> KEM.EncapsulationResult
```

## Return Value

Return Value An encapsulated shared secret, that you decapsulate by calling decapsulate(_:) on the corresponding private key.
