Cipher.encrypted readonly property



The Cipher.encrypted property gets a Buffer value, containing the data encrypted previously by the Cipher:encrypt() 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 = "*" -- encrypt the entered message 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")