Skip to content
Encoding & cryptographyReference

crypt.generatekey

Generate a Base64-encoded 256-bit key.

Details#

Generate a Base64-encoded 256-bit key. Base64 text encoding 32 random bytes. Random-generator failure raises an error.

Signature#

Luau
crypt.generatekey(): string

Returns#

Base64 text encoding 32 random bytes. Random-generator failure raises an error.

Examples#

Local example

Luau
local key = crypt.generatekey()
print(#crypt.base64decode(key)) -- 32