crypto.generate(length)

Generate binary data with cryptographically random bytes.

Parameters

length

A number representing the length in bytes of the data to be generated.

Return value

Returns a Buffer containing the random bytes.

Example

local crypto = require "crypto" local console = require "console" local random_integer = crypto.generate(8):unpack("I8") console.write("Cryptographically random integer value : ") console.writecolor("lightred",random_integer, "\n")