Skip to main content
Version: 7.2402.x.x RR

Encrypter object methods

MethodDescriptionSample
cipher = encrypter:encrypt(data)Encrypts the given data using AES-128 CBC. The input is interpreted as an ASCII string (1 byte per character), but it is not limited to ASCII characters. For non-ASCII values, use \x00 - \xFF. The result is always text-based. The AES cipher message is Base64- characters. Fhe output of repeated encrypt calls may be different with the same input as the random salt makes them highly likely to be different.cipher = encrypter:encrypt("hello world")
decoded, decryptStatus = encrypter:decrypt(data)Decrypts the given data. The first result is the given data. The second result is the status of the decryption: "ok" or "error".data, decryptStatus = encrypter:decrypt(cipher)

Example

local cryptoPass = "12345678901234567890123456789012"
local cryptoEngine = nevis.crypto.encrypter.new(cryptoPass)
local encryptedData = cryptoEngine:encrypt("SecretData100")
local plaintext, decryptStatus = cryptoEngine:decrypt(ciphertext)
if decryptStatus == "ok" then
--Decryption successful
else
--Decryption failed
end

You can find an example configuration in examples/various/LuaFilter_encrypt_store.example in the installed nevisProxy package.