syn.crypt.random Synchronous

  • syn.crypto.random

Get raw random bytes through the optional Synapse crypto namespace. Choose this when a consumer needs binary bytes rather than printable text.

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

Parameters

Function parameters
ParameterTypeDescription
lengthnumberInteger byte count from 0 through 1024.

Returns

string

A raw byte string of the requested length.

Usage notes

The result may contain zero bytes. Encode it before placing it in JSON or showing it to a person.

Availability

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

Example

Example
Luau
local bytes = syn.crypt.random(16)
print("random byte count:", #bytes)
print(base64encode(bytes))
Kawaii documentation