No infinite loop with password policy with long password with not enough upper, numerical and special characters

This commit is contained in:
Olov Karlsson 2014-11-08 16:01:20 +01:00
parent 2a1f0a3dbb
commit d8dd7d8ae5

View file

@ -111,7 +111,13 @@ function nchar(num) {
}
var pass = "";
var pas_chars = [];
var _Lower = _maxLength - _Upper - _Number - _Special;
var _Lower = _maxLength - _Upper - _Number - _Special;
while (_Lower > 26) {
_Upper++;
_Number++;
_Special++;
_Lower = _maxLength - _Upper - _Number - _Special;
}
getRandomChars([0, 22], _Special, pas_chars);
getRandomChars([23, 32], _Number, pas_chars);
getRandomChars([33, 58], _Upper, pas_chars);
@ -120,6 +126,6 @@ function nchar(num) {
pass = mixCharArray(pas_chars);
document.getElementById(txt1).value = pass;
document.getElementById(txt2).value = pass;
}
document.getElementById(txt2).value = pass;
}