klyn.cryptography.Cipher.aesDecrypt
method
public static aesDecrypt(payload as AESCipherText, key as String, keyEncoding as String = "base64", aad as String = null) as String throws CryptoException:
Description

Decrypts an AES payload produced by aesEncrypt.

Parameters
ParameterDescription
payloadStructured AES payload.
keyAES key material.
keyEncodingKey encoding: base64, base64url, hex or utf8.
aadOptional additional authenticated data for GCM.
Returns

Decrypted UTF-8 text.

Throws
  • CryptoException when authentication or decryption fails.
Example
import klyn.cryptography

key = AESKeyGenerator().generateKey()
payload = Cipher.aesEncrypt("hello", key)
print(Cipher.aesDecrypt(payload, key))