syn.crypt.random Synchronous

  • syn.crypto.random

Generate random bytes through the Synapse compatibility library. Use it when this compatibility library needs raw random key material. Encode the bytes separately if the next operation requires printable text.

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

Parameters

Function parameters
ParameterTypeDescription
lengthnumberInteger byte count from 0 through 1024.

Returns

string

Raw bytes as a string. Encode them separately when printable text is required.

Availability

This function requires the Synapse environment setting, which is off by default.

Example

Example
Luau
-- Enable the Synapse environment setting first.
local bytes = syn.crypt.random(24)
print(#bytes) -- 24
print(base64encode(bytes))
Kawaii documentation