Skip to content

Instantly share code, notes, and snippets.

@js2me
Created February 3, 2019 23:05
Show Gist options
  • Save js2me/488adcc3649d8f3695404a53e6c93555 to your computer and use it in GitHub Desktop.
Save js2me/488adcc3649d8f3695404a53e6c93555 to your computer and use it in GitHub Desktop.
Generate hard password with using JavaScript <3
export const generatePassword = (
length = 16,
stringWithChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
) => {
var pass = ''
const chars = stringWithChars.split('')
for (var j = 0; j < length; j++) {
pass = pass + chars[Math.floor(Math.random() * (chars.length - 1 + 1))]
}
return pass
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment