https://github.com/technologiespro/fisher-yates-crypto
Fisher-Yates Shuffle Implementation in JavaScript with cryptographically strong random number generator
https://github.com/technologiespro/fisher-yates-crypto
Last synced: 9 months ago
JSON representation
Fisher-Yates Shuffle Implementation in JavaScript with cryptographically strong random number generator
- Host: GitHub
- URL: https://github.com/technologiespro/fisher-yates-crypto
- Owner: technologiespro
- License: mit
- Created: 2019-09-17T10:53:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-17T12:50:02.000Z (over 6 years ago)
- Last Synced: 2025-08-29T19:22:18.025Z (10 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fisher-yates-crypto
[Fisher-Yates Shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_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
```js
const shuffleCrypto = require('fisher-yates-crypto')
const deck = ['A', 'B', 'C', 'D']
const shuffledDeck = shuffleCrypto(deck)
```
```js
const randomizer = function() {
return 0.6361052929345046
};
const shuffleCrypto = require('fisher-yates-crypto')
const deck = ['A', 'B', 'C', 'D']
const shuffledDeck = shuffleCrypto(deck, randomizer())
```