ReferenceEncoding and crypto

crypt.generatekey

Creates a random 32-byte key and returns it as Base64 text.

Syntax

crypt.generatekey() -> string

Returns

TypeDescription
stringBase64-encoded 256-bit key.

Description

The result can be passed directly to crypt.encrypt and crypt.decrypt. It is not a password and does not need hashing before use with those functions. Keep the same key for decryption; generating another key will not recover an earlier message.

Example

local key = crypt.generatekey()
print(#base64decode(key))

These are Game executor contracts. Check build requirements and session lifetimes before using them.