arc4random
v1.2.0 arc4random arc4random_buf arc4random_uniform random numbers
arc4random
Native bindings for the arc4random()
family of funcitons:
arc4random()
arc4random_buf(buf, nbytes)
arc4random_uniform(upper_bound)
Requirements
Installation
The latest and greatest version of this software is available through npm.
npm install arc4random
Usage
const rng = require('arc4random');
// returns an integer in the range [0, 2^32)
const randomNumber = rng.arc4random();
// stores nbytes integers in the given buffer.
// each byte is an integer in the range [0, 256)
const nbytes = 255;
const buf = Buffer.alloc(nbytes);
rng.arc4random_buf(buf, nbytes);
// returns an integer in the range [0, upper_bound)
const anotherRandomNumber = rng.arc4random_uniform(16);
License
See LICENSE.md
npm i [email protected]
Metadata
- ISC
- ^0.10.16 || ^0.11.13
- Thomas Cort
- released 1/9/2015