Skip to content

Instantly share code, notes, and snippets.

View CADawg's full-sized avatar
🖊️
Writing (about) new projects (at cadawg.com)

Conor CADawg

🖊️
Writing (about) new projects (at cadawg.com)
View GitHub Profile
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);