secure-chance
v2.0.0
Published
Create an instance of Chance with a truly random seed.
Downloads
36
Maintainers
Readme
secure-chance 
Create an instance of Chance with a truly random seed.
Install
npm install secure-chance
Why
Chance currently uses a Mersenne Twister seeded by Math.random()
for randomness.
The problem with this is that Math.random()
is not cryptographically secure as it was never required in the specification.
secure-chance
fixes this issue by generating a random seed using quantum randomness provided by qrng.anu.edu.au with a fallback to secure offline methods like the Node.js Crypto API or the Web Crypto API.
Usage
const secureChance = require("secure-chance")
const chance = await secureChance()
chance.integer({ min: -20, max: 20 })
chance.string({ length: 5 })
API
secureChance()
Returns a promise which resolves with an instance of Chance.