crypt.random Synchronous

Generate random bytes as a raw string. Use it when an operation expects raw random bytes rather than a printable string. Convert to Base64 for display or text storage.

Syntax
Luau
crypt.random(length: number) -> string

Parameters

Function parameters
ParameterTypeDescription
lengthnumberInteger byte count from 0 through 512.

Returns

string

Raw bytes, which can include non-printable characters and zero bytes.

Example

Example
Luau
local bytes = crypt.random(16)
print(#bytes) -- 16
print(base64encode(bytes))
Kawaii documentation