fisher-yates-crypto

Fisher-Yates Shuffle Implementation in JavaScript with cryptographically strong random number generator

Usage no npm install needed!

<script type="module">
  import fisherYatesCrypto from 'https://cdn.skypack.dev/fisher-yates-crypto';
</script>

README

fisher-yates-crypto

Fisher-Yates Shuffle Implementation in JavaScript with default cryptographically strong random number generator. Designed to be a drop-in replacement for Math.random. Can be used with Node or in a browser.

Requirements

  • NodeJS 6+

Installation

npm install fisher-yates-crypto --save

Usage

const shuffleCrypto = require('fisher-yates-crypto')
const deck = ['A', 'B', 'C', 'D']
const shuffledDeck = shuffleCrypto(deck)
const randomizer = function() {
    return 0.6361052929345046
};
const shuffleCrypto = require('fisher-yates-crypto')
const deck = ['A', 'B', 'C', 'D']
const shuffledDeck = shuffleCrypto(deck, randomizer())