C++密码安全检测
目标
关键代码
int getScore(string s)
{
int score = 0;
for (int i = 0; i < s.size(); ++i) {
char currentLetter = s[i];
if (isdigit(currentLetter))
score += scoreOfNumber;
else if (isalpha(currentLetter)) {
int ascii = currentLetter;
if (ascii <= 0x5A) // Upper-case
score += scoreOfUCaseLetter;
else
score += scoreOfLetter;
} else
score += scoreOfSpecialChar;
}
return score;
}
效果
This password is safe. Score: 122 of 100
参考
GitHub - GordonZhang2024/Password-security-checker: A simple-but-useful password security checker written in C++