Skip to content
Encoding & cryptographyReference

crypt.generatebytes

Generate random bytes and return them as Base64.

Details#

Generate random bytes and return them as Base64. Base64 text representing size bytes; 0 returns an empty string.

Signature#

Luau
crypt.generatebytes(size: number): string

Parameters#

ParameterTypeDescription
sizenumberInteger byte count from 0 to 1048576.

Returns#

Base64 text representing size bytes; 0 returns an empty string.

Examples#

Local example

Luau
local encoded = crypt.generatebytes(16)
print(#crypt.base64decode(encoded)) -- 16