Skip to content

Instantly share code, notes, and snippets.

@cyrilf
Created October 18, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrilf/24d4b2da9a35e6b555550be88b543931 to your computer and use it in GitHub Desktop.
Save cyrilf/24d4b2da9a35e6b555550be88b543931 to your computer and use it in GitHub Desktop.
Simple password generator in JS
// 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