hmac-rng

1.1.0 • Public • Published

hmac-rng

Version (npm) Build Status Code Coverage Code Climate

HMAC-based random number generator written in JavaScript.

API Reference

HmacRng ⏏

Kind: Exported class

new HmacRng(seed, [algorithm])

Creates a new HMAC-RNG instance.

Param Type Default Description
seed string Seed used for randomization.
[algorithm] string "sha512" Cryptographical algorithm to use HMAC with.

hmacRng.nextInt(min, max) ⇒ number

Gets the next random integer in the current sequence. The maximum range of 'min' and 'max' is 2^28 (268435456).

Kind: instance method of HmacRng
Returns: number - The generated random integer.

Param Type Description
min number Inclusive lower bound of the random integer returned.
max number Inclusive upper bound of the random integer returned. This must be greater than 'min'.

hmacRng.nextInts(min, max, amount) ⇒ Array.<number>

Gets the next random integers in the current sequence. The maximum range of 'min' and 'max' is 2^28 (268435456).

Kind: instance method of HmacRng
Returns: Array.<number> - The generated array of random integers.

Param Type Description
min number Inclusive lower bound of the random integers returned.
max number Inclusive upper bound of the random integers returned. This must be greater than 'min'.
amount number Amount of integers to be generated.

HmacRng.getRandomInt(seed, min, max) ⇒ number

Generates a random integer using the default algorithm. The maximum range of 'min' and 'max' is 2^28 (268435456).

Kind: static method of HmacRng
Returns: number - The generated random integer.
Since: 1.1.0

Param Type Description
seed string Seed used for randomization.
min number Inclusive lower bound of the random integer returned.
max number Inclusive upper bound of the random integer returned. This must be greater than 'min'.

HmacRng.getRandomInts(seed, min, max, amount) ⇒ Array.<number>

Generates random integers using the default algorithm. The maximum range of 'min' and 'max' is 2^28 (268435456).

Kind: static method of HmacRng
Returns: Array.<number> - The generated array of random integers.
Since: 1.1.0

Param Type Description
seed string Seed used for randomization.
min number Inclusive lower bound of the random integers returned.
max number Inclusive upper bound of the random integers returned. This must be greater than 'min'.
amount number Amount of integers to be generated.

HmacRng.shuffleArray(seed, array) ⇒ Array.<Object>

Shuffles the given array using the default algorithm.

Kind: static method of HmacRng
Returns: Array.<Object> - The array which has been shuffled.
Since: 1.1.0

Param Type Description
seed string Seed used for randomization.
array Array.<Object> Array to be shuffled.

Package Sidebar

Install

npm i hmac-rng

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • kripod