passwordStrength function
This method returns the strength of a password on a scale from one to ten as an integer.
Implementation
int passwordStrength(String password) {
int result = 0;
List<String> charList = password.split('');
for (int i = 1; i < charList.length; i++) {
String currentItem = charList[i];
String currentItemType = charType(currentItem);
String lastItem = charList[i - 1];
String lastItemType = charType(lastItem);
if (currentItemType == 'normChar' && lastItemType == 'normChar') {
int itemSpace = getCharSpace(currentItem, lastItem);
if (itemSpace > securityWeight) {
result = result + arabicCharacterWeight;
} else {
// Do nothing.
}
} else if (currentItemType == 'specialChar' &&
lastItemType == 'specialChar') {
result = result + specialCharacterWeight;
} else if (currentItemType == 'int' && lastItemType == 'int') {
int itemSpace = getNumberSpace(currentItem, lastItem);
if (itemSpace > securityWeight) {
result = result + arabicCharacterWeight;
} else {
// Do nothing.
}
}
}
return result;
}