klyn.cryptography.Cipher.aesEncrypt
method
public static aesEncrypt(plainText as String, key as String, mode as String = "GCM", keyEncoding as String = "base64", iv as String = null, ivEncoding as String = "base64", aad as String = null) as AESCipherText throws CryptoException:
DescriptionEncrypts text with AES.
Supported modes are `GCM`, `CBC` and `CTR`.
Defaults are optimized for the common case:
- `mode = "GCM"`
- `keyEncoding = "base64"` so it works directly with `KeyGenerator`
- random IV generation when `iv` is omitted
import klyn.cryptography
key = AESKeyGenerator().generateKey()
payload = Cipher.aesEncrypt("hello", key)
print(payload.cipherTextBase64)
ReturnsStructured AES payload.