Crypto
randomInt

🔢 Generates a cryptographically secure random integer between min (inclusive) and max (exclusive).

Syntax

import { randomInt } from '@opentf/std';
 
randomInt(min: number = 0, max: number = 100): number;

Parameters

  • min: The minimum value (inclusive).
  • max: The maximum value (exclusive).

Returns

A random integer.

Examples

randomInt() //=> 42 (between 0 and 100)
randomInt(1, 11) //=> 7 (between 1 and 10)

Related

Try