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.
Luau
syn.crypt.random(length: number) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
length | number | Integer byte count from 0 through 1024. |
Returns
stringRaw 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
Luau
-- Enable the Synapse environment setting first.
local bytes = syn.crypt.random(24)
print(#bytes) -- 24
print(base64encode(bytes))