Skip to content

01 AES Encryption and Decryption

romantsisyk edited this page Nov 27, 2024 · 2 revisions

ES Encryption and Decryption

Overview

AES (Advanced Encryption Standard) is used for symmetric encryption. CryptoKit uses the AES-GCM mode for secure encryption.

API Reference

  • CryptoKit.encryptAES(data: String, key: String): String
  • CryptoKit.decryptAES(data: String, key: String): String

Example

// 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")

Notes

  • Ensure the key length matches the AES-GCM requirements.
  • Encrypted data is returned as Base64-encoded.

Clone this wiki locally