Skip to main content

Access

All crypto C++ functions are exposed to your Lua script via a single global table named crypto. You access individual values by using the dot (.) or bracket ([]) operator on this table.
Crypto Usage Example

Functions

This section lists all available C++ functions exposed within the global crypto table. These functions provide utilities for hashing, encoding/decoding data (like Base64 and Hex), and generating cryptographic primitives.

base64_encode

Encodes a string to Base64 format. Returns the Base64-encoded string.
string
required
The string to encode in Base64 format.

base64_decode

Decodes a Base64-encoded string back to its original format. Returns the decoded string, or "Unknown" if decoding fails.
string
required
The Base64-encoded string to decode.

hex_encode

Encodes a string to hexadecimal format. Returns the hexadecimal-encoded string.
string
required
The string to encode in hexadecimal format.

hex_decode

Decodes a hexadecimal-encoded string back to its original format. Returns the decoded string, or "Unknown" if decoding fails.
string
required
The hexadecimal-encoded string to decode.

hash_sha256

Computes the SHA-256 hash of a string. Returns the hash as a string.
string
required
The string to hash using SHA-256.

hash_sha512

Computes the SHA-512 hash of a string. Returns the hash as a string.
string
required
The string to hash using SHA-512.

hash_blake2b

Computes the BLAKE2b hash of a string with a specified output size. Returns the hash as a string, or "Invalid size" if the size exceeds the maximum, or "Unknown" if hashing fails.
string
required
The string to hash using BLAKE2b.
number
required
The desired output size of the hash in bytes. Must not exceed the maximum allowed size.

generate_key

Generates a cryptographically secure random key of the specified size. Returns the generated key as a string.
number
required
The size of the key to generate in bytes.

generate_nonce

Generates a cryptographically secure random nonce suitable for use with encryption operations. Returns the generated nonce as a string.