Volt

crypt.generatebytes

Generates cryptographically secure random bytes.

Syntax

crypt.generatebytes(length: number) -> string

Parameters

ParameterTypeDescription
lengthnumberNumber of bytes to generate

Returns

TypeDescription
stringRandom bytes (raw string)

Description

crypt.generatebytes generates cryptographically secure random bytes, useful for creating initialization vectors, salts, or other random data.

Example

-- Generate 16 bytes for an IV
local iv = crypt.generatebytes(16)

-- Generate 32 bytes for a salt
local salt = crypt.generatebytes(32)

On this page