I'm trying to encrypt a string with RSA, I already got a publicKey(String type) from the server. How can I get the secKey without "SecKeyCreateWithData", because this method only supports ios10+ ? But it has to support to ios8.0+.
if #available(iOS 10.0, *) {
guard let secKey = SecKeyCreateWithData(data as CFData, attributes, &error) else {
print(error.debugDescription)
return nil
}
} else {
//how can I do here?
}
CoreCrypto
and Security
is seemingly only supported from iOS 10
onwards (as you've discovered).
You have two options:
1) Generate the RSA components manually, rolling your own implementation (Suggest you avoid this approach).
2) Switch to a modern cross platform crypto library, eg libsodium. (Doesn't support RSA, all EC based for asymmetric crypto).
Apple also have CryptoKit
but that doesn't support < iOS 13
.
If you add some extra info about your use-case I will happily suggest further options.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.