Cipher.decrypted readonly property
The Cipher.decrypted property gets Buffer value, containing the data decrypted previously by the Cipher:decrypt() method.
Example
local crypto = require "crypto"
local console = require "console"
-- randomly generate a secret key (16 bytes long)
local key = crypto.generate(16)
-- create a cipher using AES128 algorithm and the generated key
local cipher = crypto.Cipher("aes128", key)
console.echo = "*"
local nbytes = cipher:encrypt(console.readln("\nEnter a secret message : "))
console.write("Encrypted message : ")
-- prints the encrypted result using base64 encoding
console.writecolor("lightgreen", cipher.encrypted:encode("base64"), "\n")
-- decrypt the secret message
nbytes = cipher:decrypt(cipher.encrypted)
console.write("Decrypted message : ")
-- prints the decrypted result
console.writecolor("lightgreen", cipher.decrypted, "\n")