Cipher:decrypt(data)method

Decrypt the specified data.

Parameters

data

A Buffer or a string containing the data to be decrypted. The Cipher object uses an internal decryption buffer, so that sucessive calls to this method appends the decrypted data to this internal buffer. That permits to decrypt data from various streams easily.
Use the property Cipher.decrypted to retrieve the whole decrypted data.

Return value

Returns the number of bytes decrypted.

Example

-- File decryption -- see example at cipher:encrypt() import crypto local console = require "console" local cipher = crypto.Cipher("aes128", "its_a_secret_key") -- decrypt file local file = sys.File("encrypted.dat") print("Successfully decrypted "..cipher:decrypt(file:open():read()).." bytes") -- prints the decrypted data as UTF8 console.writecolor("green", cipher.decrypted)