Sandbox: Lua: Crypto - ov-studio/Vital.sandbox GitHub Wiki

━ What's the Objective?

Vital exposes custom crypto module (hashing, encoding/decoding, encrypting/decrypting) to suit various sandboxing strategies since Lua provides none natively.

━ Hash Modes

  • SHA1
  • SHA224
  • SHA256
  • SHA384
  • SHA512

━ Encryption Modes

  • AES128 | Key: 16 characters
  • AES192 | Key: 24 characters
  • AES256 | Key: 32 characters

━ APIs

━ crypto.hash() (Shared)

@Objective: Hashes provided buffer using specified alogrithm.
local string: result = crypto.hash(
  string: mode, --Hash mode to use (Refer the attached list above)
  string: buffer
)

━ crypto.encode() (Shared)

@Objective: Encodes provided buffer.
local string: result = crypto.encode(
  string: buffer
)

━ crypto.decode() (Shared)

@Objective: Decodes provided buffer.
local string: result = crypto.decode(
  string: buffer
)

━ crypto.encrypt() (Shared)

@Objective: Encrypts provided buffer using specified alogrithm.
local string: result, string: iv = crypto.encrypt(
  string: mode, --Encryption mode to use (Refer the attached list above)
  string: buffer,
  string: key
)

━ crypto.decrypt() (Shared)

@Objective: Decrypts provided buffer using specified alogrithm.
⚠️ Exact IV given by crypto.encrypt() must be provided for successful decryption.
local string: result, string: iv = crypto.decrypt(
  string: mode, --Encryption mode to use (Refer the attached list above)
  string: buffer,
  string: key,
  string: iv
)