crypt. generatebytes Synchronous
Generate random bytes and return them encoded as Base64. Use it when a random value must already be printable, such as a randomly generated local label. Requesting 16 bytes does not mean the Base64 result has 16 characters.
Luau
crypt.generatebytes(length: number) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
length | number | Number of random bytes before encoding. Must be an integer from 0 through 512. |
Returns
stringBase64 text. The string length after encoding differs from the requested byte count.
Example
Luau
local encoded = crypt.generatebytes(16)
local bytes = base64decode(encoded)
print(#bytes) -- 16