function evaluatePassword(password) { var points = 0; var minPoints = 6; var passwordArr = password.split(''); var valueList = { number: { used: false, points: 2 }, symbol: { used: false, points: 2 }, char: { used: false, points: 1 }, eightChars: { used: false, points: 4 } }; function addPoints(char) { if (!isNaN(parseInt(char)) && !valueList.number.used) { valueList.number.used = true; points += valueList.number.points; } else { if (/[-!$%^&*()_+|~=`{}\[\]:";'?,.\/]/.test(char) && !valueList.symbol.used) { valueList.symbol.used = true; points += valueList.symbol.points; } else if (!valueList.char.used) { valueList.char.used = true; points += valueList.char.points; } } } if (passwordArr.length >= 8) { points += valueList.eightChars.points; } for (var i = 0; i = minPoints) { return 'Password is strong for ' + points + ' pts'; } return 'Password not strong with ' + points + ' pts'; }
Оцените надежность пароля JS
schedule
04.12.2022