<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "LocalAuthentication",
  "identifier" : "/documentation/LocalAuthentication/LAPublicKey/canEncrypt(using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Local Authentication"
    ],
    "preciseIdentifier" : "c:objc(cs)LAPublicKey(im)canEncryptUsingSecKeyAlgorithm:"
  },
  "title" : "canEncrypt(using:)"
}
-->

# canEncrypt(using:)

Checks whether the algorithm you supply is valid for encrypting data with the key.

```
func canEncrypt(using algorithm: SecKeyAlgorithm) -> Bool
```

## Parameters

`algorithm`

A cryptographic algorithm.

## Return Value

A Boolean value that indicates whether the algorithm you supply is valid for encrypting data with the key.

## Discussion

---

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)