https://github.com/tcort/arc4random
Native bindings for the arc4random() family of funcitons.
https://github.com/tcort/arc4random
arc4random libbsd native-bindings nodejs
Last synced: 7 months ago
JSON representation
Native bindings for the arc4random() family of funcitons.
- Host: GitHub
- URL: https://github.com/tcort/arc4random
- Owner: tcort
- License: isc
- Created: 2014-12-19T23:37:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-05-21T13:56:11.000Z (almost 8 years ago)
- Last Synced: 2024-11-21T08:39:56.281Z (over 1 year ago)
- Topics: arc4random, libbsd, native-bindings, nodejs
- Language: JavaScript
- Size: 46.9 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
arc4random
==========
Native bindings for the `arc4random()` family of funcitons:
* `arc4random()`
* `arc4random_buf(buf, nbytes)`
* `arc4random_uniform(upper_bound)`
Requirements
------------
* [nodejs](http://nodejs.org/) or [iojs](https://iojs.org/)
* Operating system with a native `arc4random()` function or [libbsd](http://libbsd.freedesktop.org/):
* [Mac OS X (darwin)](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/arc4random.3.html)
* [FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=arc4random&sektion=3)
* [OpenBSD](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/arc4random.3?query=arc4random&sec=3)
* [NetBSD](http://netbsd.gw.com/cgi-bin/man-cgi?arc4random++NetBSD-current)
* [Linux via libbsd](http://libbsd.freedesktop.org)
Installation
------------
The latest and greatest version of this software is available through [npm](http://npmjs.org/).
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](https://github.com/tcort/arc4random/blob/master/LICENSE.md)