---
title: "decrypt(_:algorithm:completion:)"
framework: localauthentication
role: symbol
role_heading: Instance Method
path: "localauthentication/laprivatekey/decrypt(_:algorithm:completion:)"
---

# decrypt(_:algorithm:completion:)

Decrypts the data you supply with a given algorithm.

## Declaration

```swift
func decrypt(_ data: Data, algorithm: SecKeyAlgorithm, completion handler: @escaping @Sendable (Data?, (any Error)?) -> Void)
```

```swift
func decrypt(_ data: Data, algorithm: SecKeyAlgorithm) async throws -> Data
```

## Parameters

- `data`: The data to decrypt.
- `algorithm`: The algorithm to use to decrypt the data.
- `handler`: A completion handler to call when the decryption operation completes.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func decrypt(_ data: Data, algorithm: SecKeyAlgorithm) async throws -> Data For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Performing cryptographic operations

- [exchangeKeys(publicKey:algorithm:parameters:completion:)](localauthentication/laprivatekey/exchangekeys(publickey:algorithm:parameters:completion:).md)
- [sign(_:algorithm:completion:)](localauthentication/laprivatekey/sign(_:algorithm:completion:).md)
