mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2024-10-01 01:35:57 -04:00
modularized random number generation logic
This commit is contained in:
parent
b38eadd4ed
commit
e13220c2fb
@ -1,6 +1,9 @@
|
||||
var passwordGenerator = (function() {
|
||||
return {
|
||||
generatePassword: function (options) {
|
||||
var generateRandomNum = function (max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
};
|
||||
|
||||
var generatePassword = function (options) {
|
||||
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
||||
var lowercase = "abcdefghiklmnopqrstuvwxyz";
|
||||
var numbers = "0123456789";
|
||||
@ -20,10 +23,13 @@ var passwordGenerator = (function() {
|
||||
}
|
||||
var result = "";
|
||||
for (var i = 0; i < options.passwordLength; i++) {
|
||||
var randomNum = Math.floor(Math.random() * candidates.length);
|
||||
var randomNum = generateRandomNum(candidates.length);
|
||||
result += candidates.substring(randomNum, randomNum + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
generatePassword: generatePassword
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user