Generates a random integer that fits the given number of bits.
The result is generated using the cryptographically secure random number generator.
bits(n)
n
The number of bits the generated number should fit.
If the number of bits is in the range that can be represented as an integer number (that is, less than or equal to 53), the result will be a number, if it’s larger, the result will be a BigInt.
A random number (number or BigInt).
random.bits(1)
1
random.bits(32)
1565947894
random.bits(128)
187758866319927604793308803227993543831