我正在使用以下代码创建密钥
let tag = "com.example.keys.mykey".data(using: .utf8)!
let attributes: [String: Any] =
[kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
kSecAttrKeySizeInBits as String: 256,
kSecPrivateKeyAttrs as String:
[kSecAttrIsPermanent as String: true,
kSecAttrApplicationTag as String: tag]]
guard let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, &error) else {
throw error!.takeRetainedValue() as Error}
字符串
使用获取公钥
let publicKey = SecKeyCopyPublicKey(privateKey)
型
1条答案
按热度按时间tyu7yeag1#
字符串
通过传递公钥来调用convertSecKeyToDerKeyFormat函数。