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.
Luau
syn.crypt.random(length: number) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
length | number | Integer byte count from 0 through 1024. |
Returns
stringA 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
Luau
local bytes = syn.crypt.random(16)
print("random byte count:", #bytes)
print(base64encode(bytes))