Created
November 2, 2017 09:34
-
-
Save darrenmothersele/7cd24da0f35d450babd4745c7f208acf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
let array = new Uint8Array(40); | |
window.crypto.getRandomValues(array); | |
array = array.map(x => validChars.charCodeAt(x % validChars.length)); | |
const randomState = String.fromCharCode.apply(null, array); | |
console.log(randomState); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is exactly what I wanted!