Giter VIP home page Giter VIP logo

isaacjs's Introduction

ISAACJS

This is a javascript implementation of the ISAAC CSPRNG.

It's ~261.95% faster than the readable implementation by rubycon at tumbling, and ~231.88% faster at returning random numbers.

Due to the focus on speed ISAACJS has not been made with the intention of being readable.

ISAAC-64

I have additionally implemented ISAAC-64 using BigInt. Please for the love of god don't actually use it; it's a PoC, slow, and ridiculous.

ISAAC-64-fast uses a simulated 64-bit integer object by having a hi and lo 32-bit integer. It's 3x faster than the BigInt version. It's still too slow to be useful and I don't trust my hi/lo arithmetic.

Usage

Create an instance of ISAAC with or without a seed.

var rng = new ISAAC(); //No seed
var rng = new ISAAC(new Uint32Array(ISAAC.prototype.SIZE)); //Zero seed
var rng = new ISAAC(ISAAC.StringToUintArray("This is a test")); //Text seed

Tumble it an arbitrary amount of times

rng.Isaac(); //Tumble once

for(var i = 0; i < 5; i++) rng.Isaac(); //Tumble five times

Tada! Go get yourself some random numbers!

rng.Rand(); //Will get the next available random 32bit unsigned integer and re-tumble it if it has run out
rng.rsl[0]; //Alternatively you can access the internal result array

Compatibility

Tested and working in Chrome, Firefox, IE11, and Edge.

License

This project is licensed under the CC0 license, meaning it is effectively public domain.

isaacjs's People

Contributors

alphadelta avatar

Watchers

 avatar  avatar

Forkers

5l1v3r1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.