The isaac-prng package provides a TypeScript (JavaScript) implementation of the ISAAC secure random number generator.
ISAAC is a CSPRNG designed by Robert J. Jenkins Jr. in 1996 and based on RC4. It is designed to be fast and secure.
isaac-prng is fully compatible with other implementations of ISAAC and can be used as a good alternative to the default javascript Math.random()
function. It utilizes JavaScript's new BigInt data type to avoid having to work around the inherent limitations of JavaScript's Number data type.
The implementation was adapted from Bob Jenkin's Java port of his original C implementation. ISAAC, the algorithm/cipher/generator is a work released into the public domain. This software implementation, however, is released under the MIT license.
npm install isaac-prng
import { Isaac } from 'isaac-prng'
Create an instance of Isaac without a seed.
const isaac = new Isaac()
If you wish to modify the seed, you can do so by supplying an array of Numbers. Find some random source data to pass in.
const isaac = new Isaac([ 1, 2, 3, 4 ])
Generate the next random number.
const randomNumber = isaac.nextInt()
console.log(randomNumber)