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
local base64_encoded_string = crypto.base64_encode("Hai =^,..,^= lf trx coin hydraulic press erc20 tron coin payment"); -- Dot Operator
local base64_decoded_string = crypto["base64_decode"](base64_encoded_string); -- Bracket Operator

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.
base64_encode(string: value): string
value
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.
base64_decode(string: value): string
value
string
required
The Base64-encoded string to decode.

hex_encode

Encodes a string to hexadecimal format. Returns the hexadecimal-encoded string.
hex_encode(string: value): string
value
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.
hex_decode(string: value): string
value
string
required
The hexadecimal-encoded string to decode.

hash_sha256

Computes the SHA-256 hash of a string. Returns the hash as a string.
hash_sha256(string: value): string
value
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.
hash_sha512(string: value): string
value
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.
hash_blake2b(string: value, number: size): string
value
string
required
The string to hash using BLAKE2b.
size
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.
generate_key(number: size): string
size
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.
generate_nonce(): string
I