0.4.0 • Published 6 years ago

rejection-sampled-int v0.4.0

Weekly downloads
373
License
MIT
Repository
github
Last release
6 years ago

rejection-sampled-int

Build Status npm install js-standard-style

Cryptographically random integers, chosen by a rejection sampling algorithm.

Warning: I am not a cryptographer, or any sort of random number expert. An audit would be greatly appreciated.

Installation

To install the module for use in your projects:

npm install rejection-sampled-int

This library includes TypeScript definitions, and should be discovered automatically by the TypeScript compiler.

Usage

var rand = require('rejection-sampled-int')

rand.sync({max: 128}) // 56
rand.sync({min: 10, max: 16}) // 11
rand({min: 10, max: 16}, (err, int) => int) // 13
rand({min: 10, max: 16}).then(int => int) // 10
rand.sync() // 8882371922968183

API

  • rand({min = 0, max = Number.MAX_SAFE_INT}, [ready(err, int)]) Get an integer between min (inclusive) and max (exclusive). If ready is not provided, a Promise is returned.
  • rand.sync({min = 0, max = Number.MAX_SAFE_INT}) Get an integer between min (inclusive) and max (exclusive), synchronously.

License

MIT. See LICENSE for details.

0.4.0

6 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago