Thanks for answering!
Based on our guideline, we are supposed to use AES-CBC for encryption.
And I generated a random 256-bits symmetric key to achieve this. (Please find the code snippets below.)
I have a question here - how can I store such a symmetric key into keychain? Thanks!
internal func generateSymmetricEncryptionKey() throws -> String {
var keyData = Data(count: 32)
let result = keyData.withUnsafeMutableBytes {
SecRandomCopyBytes(kSecRandomDefault, 32, $0.baseAddress!)
}
guard result == errSecSuccess else {
throw error
}
return keyData.base64EncodedString()
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: