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.
Luau
crypt.random(length: number) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
length | number | Integer byte count from 0 through 512. |
Returns
stringRaw bytes, which can include non-printable characters and zero bytes.
Example
Luau
local bytes = crypt.random(16)
print(#bytes) -- 16
print(base64encode(bytes))