Access
All crypto C++ functions are exposed to your Lua script via a single global table namedcrypto
. 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 globalcrypto
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.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.
The Base64-encoded string to decode.
hex_encode
Encodes a string to hexadecimal format. Returns the hexadecimal-encoded string.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.
The hexadecimal-encoded string to decode.
hash_sha256
Computes the SHA-256 hash of a string. Returns the hash as a string.The string to hash using SHA-256.
hash_sha512
Computes the SHA-512 hash of a string. Returns the hash as a string.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.
The string to hash using BLAKE2b.
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.The size of the key to generate in bytes.