Skip to main content
Returns a string of size random bytes.
Each call returns a different result. For random bytes already Base64-encoded use crypt.generatebytes; for an AES key use crypt.generatekey. Most commonly used as a raw-randomness source for tokens, salts, and nonces.

Parameters

Returns

string - size random bytes.

Example

Unlike standard math.random, this uses a secure entropy source.