Yuari
Documentation
Docs/Crypt/crypt.encrypt

crypt.encrypt

Symmetric encryption. mode defaults to CBC.

Syntax

crypt.encrypt(data: string, key: string, iv?: string, mode?: string) -> string

Parameters

ParameterTypeDescription
datastringThe data payload to process or send.
keystringThe key or secret used by the operation.
iv?stringThe iv value used by the call.
mode?stringThe cipher mode to use.

Returns

TypeDescription
stringThe returned string.

Description

crypt.encrypt is part of the Crypt library. Crypt functions process data locally. Keys, hashes and encrypted buffers remain inside the process.

The operation is performed immediately using the arguments supplied at the call site.

The aliases crypt.decrypt(data, key, iv, mode?) resolve to the same implementation.

Example

local key = crypt.generatekey(32)
local iv = crypt.generatebytes(16)
local encrypted = crypt.encrypt("secret", key, iv, "CBC")
print(crypt.decrypt(encrypted, key, iv, "CBC"))

Notes

  • Aliases: crypt.decrypt(data, key, iv, mode?).
  • Never log keys or decrypted buffers in production scripts.