2.0.3 • Published 4 years ago

xoshiro v2.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Xoshiro

Node.js CI npm version

What is this?

A pseudo-random-number-generator module implemented in N-API. Here is all about the algorithms.

Requirements

Installation

Just run this command:

npm install --save xoshiro

Usage

const xoshiro = require('xoshiro');
const crypto = require('crypto');

// create a PRNG with an algorithm and a seed
const seed = crypto.randomBytes(32);
const prng = xoshiro.create('256+', seed);

// generate a random unsigned 32-bit integer
console.log(prng.roll());

// store the current state
let s = prng.state
// generate a random number
const x = prng.roll()
// restore the state
prng.state = s
// generate a random number from the previous state
const y = prng.roll()
// and they should be equal
console.log(x === y)  // -> true

Supported algorithms

  • '256+' xoshiro256+, requires the seed to be of at least 32 bytes
  • '256++' xoshiro256++, requires the seed to be of at least 32 bytes
  • '256**' xoshiro256**, requires the seed to be of at least 32 bytes
  • '512+' xoshiro512+, requires the seed to be of at least 64 bytes
  • '512++' xoshiro512++, requires the seed to be of at least 64 bytes
  • '512**' xoshiro512**, requires the seed to be of at least 64 bytes

Note: In order to make it work, the seed used to initialize the PRNG should not be all 0's.

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago