Created
February 3, 2019 23:05
-
-
Save js2me/488adcc3649d8f3695404a53e6c93555 to your computer and use it in GitHub Desktop.
Generate hard password with using JavaScript <3
This file contains hidden or 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
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