-
Notifications
You must be signed in to change notification settings - Fork 1
01 AES Encryption and Decryption
romantsisyk edited this page Nov 27, 2024
·
2 revisions
AES (Advanced Encryption Standard) is used for symmetric encryption. CryptoKit uses the AES-GCM mode for secure encryption.
CryptoKit.encryptAES(data: String, key: String): StringCryptoKit.decryptAES(data: String, key: String): String
// Encryption
val key = "my_secure_key_123" // Ensure it's 128/192/256 bits
val data = "Sensitive Information"
val encryptedData = CryptoKit.encryptAES(data, key)
println("Encrypted: $encryptedData")
// Decryption
val decryptedData = CryptoKit.decryptAES(encryptedData, key)
println("Decrypted: $decryptedData")- Ensure the key length matches the AES-GCM requirements.
- Encrypted data is returned as Base64-encoded.