secure-chance
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

secure-chance Travis CI Build Status

Create an instance of Chance with a truly random seed.

NPM Badge

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.

Package Sidebar

Install

npm i secure-chance

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

4.3 kB

Total Files

6

Last publish

Collaborators

  • richienb