Skip to content
/ nreseed Public

Node.js reseeder for PRNGs for checkpointed processes

License

Notifications You must be signed in to change notification settings

sitano/nreseed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nreseed

node.js reseeder for PRNGs for checkpointed processes.

Addon exposes original Node.js PRNG algorithm (xor128+ + murmur3(seed)). It also reinstalls crypto api entropy.

quick start

$ npm install
$ npm test

usage

  require('nreseed').reseed();
  Math.random();

  const a = new Uint32Array(1);
  crypto.getRandomValues(a);

or

  const seeder = require('nreseed');

  const a = new seeder.PRNG();
  const b = new seeder.PRNG(0);

  a.random();
  b.random();

  b.setSeed(1);
  b.random();

  b.reseed();
  b.random();

  Math.random = function() {
    return b.random();
  };

author

Ivan P. @JohnKoepi