我一直在考虑开发一个 Android 应用程序,它会告诉用户输入密码的密码强度。
在检查密码强度方面,我开发了这两种算法来检查它。但是我正在考虑使用这些算法,因为我认为它效率不高。你们有什么感想?
这是我的2个算法:
平均法
Sample input = Password12@
1. Count the lowercase, uppercase, digits and special characters in the given String.
Eg.
Lowercase count = 7;
Uppercase count = 1;
Digits count = 2;
SpecialCharacter count = 1;
2. Get the character count and multiply it to the size of given String.
Eg.
(Count * Size)
(7 * 10) = 70
(1 * 10) = 10
(2 * 10) = 20
(1 * 10) = 10
3. Add the following results
Eg.
70 + 10 + 20 + 10 = 110
4. Get the results which is the password strength.
Eg.
The password is 110% strong.
积分法
Sample input = Password12@
1. Set the points such that for every:
Lowercase = 1 point given
Uppercase = 5 points given
Digits = 10 points given
Special Character = 15 points given
2. Count the lowercase, uppercase, digits and special characters in the given String.
Eg.
Lowercase count = 7;
Uppercase count = 1;
Digits count = 2;
SpecialCharacter count = 1;
3. Get the character count and add it to the given point and multiply the size of the given String.
Eg.
(Count + Point) * size
(7 + 1) * 10 = 80;
(1 + 5) * 10 = 60;
(2 + 10) * 10 = 120;
(1 + 15) * 10 = 160;
4. Add the following results and divide it to the size of given String and divide it by 4.
Eg.
//4 because count={uppercase, lowercase, digits, special character}
80 + 60 + 120 + 160 = 420
420 / 4 = 105
5. Get the result which is the pswword strength.
Eg.
The password strength is 105%.
我的问题是:
哪种算法表明具有更好的实现?
如果 2 种给定算法效率低下,是否有现有算法可用于检查给定密码的强度。不是这样,重新发明轮子。