Cryptography

crypt.generatebytes

Generates cryptographically secure random bytes with the requested length.

Syntax

crypt.generatebytes(length: integer): string

Arguments

NameTypeDescription
lengthintegerNumber of bytes to generate.

Returns

NameTypeDescription
bytesstringRandom byte string with the requested length.

Description

Generates cryptographically secure random bytes with the requested length.

Call it with 1 parameter(s): length. The argument table explains which values are required and which ones only refine the behavior.

It returns bytes (string). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = crypt.generatebytes(1)
print(result)