-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
27 lines (20 loc) · 838 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
osrandom
--------
Simple interface to the operating system prng. Currently only /dev/urandom is supported.
It is assumed that these sources are non-blocking in nature, so therefore sync IO calls
are used by default (async io can be used by passing a callback).
Note: Blocking stat and open calls are used on module load. It is recommended that you
require the module at least once at init time so as not to block your app later.
This should be extended to call CryptGenRandom on windows which serves the same function
as /dev/urandom.
Quick usage
-----------
// Print a buffer synchronously
var osrandom=require('osrandom');
console.log(osrandom(32).toString('base64'))
// Use asynchronously
var osrandom=require('osrandom');
osrandom(32, function(err, buffer) {
if (err) throw err;
console.log(buffer.toString('base64'));
});