klyn.cryptography.Cipher.aesCtrEncrypt
method
public static aesCtrEncrypt(plainText as String, key as String, keyEncoding as String = "base64", iv as String = null, ivEncoding as String = "base64") as AESCipherText throws CryptoException:
Description
Convenience AES-CTR encryption helper.
import klyn.cryptography

key = AESKeyGenerator().generateKey()
payload = Cipher.aesCtrEncrypt("hello", key)
print(payload.cipherTextHex)
Parameters
  • plainText Source text interpreted as UTF-8.
  • key AES key material.
  • keyEncoding Key encoding. Defaults to `base64`.
  • iv Optional IV.
  • ivEncoding IV encoding when `iv` is provided.
Returns
Structured AES-CTR payload.
Throws
  • CryptoException when encryption fails. ```klyn import klyn.cryptography key = AESKeyGenerator().generateKey() payload = Cipher.aesCtrEncrypt("hello", key) print(payload.cipherTextHex) ```