Created
October 18, 2018 14:11
-
-
Save cyrilf/24d4b2da9a35e6b555550be88b543931 to your computer and use it in GitHub Desktop.
Simple password generator in JS
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
// Add IE11 support | |
const crypto = window.crypto || window.msCrypto | |
const generatePassword = (length = 10) => { | |
const buffer = new Uint8Array(12) | |
crypto.getRandomValues(buffer) | |
return btoa(String.fromCharCode.apply(null, buffer)).substr(0, length) | |
} | |
export default generatePassword |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment