crypto-shuffle

1.0.1 • Public • Published

crypto-shuffle

Travis build status Coverage Status npm version

A cryptographically secure shuffle using the modern Fisher-Yates algorithm. The browser's (or Node.js) crypto services are used to generate strong random numbers; see get-random-values for more details.

Getting started

crypto-shuffle is available for both Node.js and the browser. Most modern browsers are supported. If you want to know if your browser is compatible, run the online test suite.

Install with npm

> npm install crypto-shuffle --save

Node

Include the package and the shuffle a deck of cards

var shuffle = require('crypto-shuffle')

var deck = ["AS", "KS", "QS", "JS", "TS", "9S"]
shuffle(deck)
console.log(deck)

Browser

Include the package from your project

<script src="./node_modules/crypto-shuffle/dist/crypto-shuffle.min.js" type="text/javascript"></script>

Or better yet, from the unpkg CDN

<script src="https://unpkg.com/crypto-shuffle/dist/crypto-shuffle"></script>

This will provide shuffle as a global object, or define it if you are using AMD.

<script>
    var deck = ["AS", "KS", "QS", "JS", "TS", "9S"]
    shuffle(deck)
    alert(deck)
</script>

Package Sidebar

Install

npm i crypto-shuffle

Weekly Downloads

1,116

Version

1.0.1

License

MIT

Last publish

Collaborators

  • makaretu