Skip to content

crypto.random

Generates a cryptographically strong sequence of random bytes.

Signature

luau
function random(length: number): string

Summary

Parameters

ParameterTypeDescription
lengthnumberThe number of bytes to generate.

Example

lua
local crypto = require("@runtime/crypto")

local bytes = crypto.random(32)
print(#bytes) -- 32