Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created November 3, 2020 01:43
Show Gist options
  • Save cardoso/d309ea2ea465899fb3e48b988a6b0961 to your computer and use it in GitHub Desktop.
Save cardoso/d309ea2ea465899fb3e48b988a6b0961 to your computer and use it in GitHub Desktop.
import Foundation
import CryptoKit
func importPublicKey(_ publicKey: String) throws -> P256.KeyAgreement.PublicKey {
let base64PublicKey = publicKey.removingPercentEncoding!
let rawPublicKey = Data(base64Encoded: base64PublicKey)!
let publicKey = try P256.KeyAgreement.PublicKey(rawRepresentation: rawPublicKey)
return publicKey
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment