crng
Generate random values from a cryptographicaly-secure random number generator in Node.js. Uses the crypto
module.
Generators
cryptoRandom01
Generate a value between 0 (inclusive) and 1 (exclusive).
;// const {cryptoRandom01} = require("crng"); ;
cryptoRandomDouble
Generate a number that is not infinite and not NaN
.
;// const {cryptoRandomDouble} = require("crng"); ;
cryptoRandomHex
Generate a string containing hexadecimal characters with n
bytes of entropy (defaults to 8
).
Note that the length of the resulting value is double the entropy amount.
;// const {cryptoRandomHex} = require("crng"); ;console.assertval.length === 16;