estimatePassword method
Result
estimatePassword(
- String password, {
- String? firstName,
- String? lastName,
- String? middleName,
- String? email,
- String? dateOfBirth,
- List<
String> ? otherInputs,
override
Check the password's strength result.score : Integer from 0-4 (useful for implementing a strength bar) 0 # too guessable: risky password. (guesses < 10^3) 1 # very guessable: protection from throttled online attacks. (guesses < 10^6) 2 # somewhat guessable: protection from unthrottled online attacks. (guesses < 10^8) 3 # safely unguessable: moderate protection from offline slow-hash scenario. (guesses < 10^10) 4 # very unguessable: strong protection from offline slow-hash scenario. (guesses >= 10^10)
result.feedback : verbal feedback to help choose better passwords. set when score <= 2.
result.calcTime : how long it took to calculate an answer in milliseconds.
Implementation
@override
Result estimatePassword(String password,
{String? firstName,
String? lastName,
String? middleName,
String? email,
String? dateOfBirth,
List<String>? otherInputs}) {
assert(password.isNotEmpty, "Password can't be empty");
var userInputs = <String>[];
if (firstName != null && firstName.isNotEmpty) {
userInputs.add(firstName);
}
if (lastName != null && lastName.isNotEmpty) {
userInputs.add(lastName);
}
if (middleName != null && middleName.isNotEmpty) {
userInputs.add(middleName);
}
if (email != null && email.isNotEmpty) {
userInputs.add(email);
}
if (dateOfBirth != null && dateOfBirth.isNotEmpty) {
userInputs.add(dateOfBirth);
}
if (otherInputs != null && otherInputs.isNotEmpty) {
userInputs.addAll(otherInputs);
}
return Zxcvbn().evaluate(password, userInputs: userInputs);
}