Skip to main content
Generates size random bytes, and returns them encoded in base64.
The returned string’s length is 4 * math.ceil(size / 3) - implying crypt.generatebytes(10) returns a 16-character string. Most commonly used to generate IVs, salts, nonces, and request tokens.

Parameters

Returns

string - sequence of random bytes, encoded in base64.

Example

Pull 16 random bytes for use as a session ID, request nonce, or salt.
Typically used to generate secure IVs or temporary nonces.