1.1.0 • Published 8 years ago

hmac-rng v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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.

ParamTypeDefaultDescription
seedstringSeed used for randomization.
algorithmstring"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.

ParamTypeDescription
minnumberInclusive lower bound of the random integer returned.
maxnumberInclusive 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.

ParamTypeDescription
minnumberInclusive lower bound of the random integers returned.
maxnumberInclusive upper bound of the random integers returned. This must be greater than 'min'.
amountnumberAmount 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

ParamTypeDescription
seedstringSeed used for randomization.
minnumberInclusive lower bound of the random integer returned.
maxnumberInclusive 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

ParamTypeDescription
seedstringSeed used for randomization.
minnumberInclusive lower bound of the random integers returned.
maxnumberInclusive upper bound of the random integers returned. This must be greater than 'min'.
amountnumberAmount 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

ParamTypeDescription
seedstringSeed used for randomization.
arrayArray.<Object>Array to be shuffled.