password_entropy 2.0.1 password_entropy: ^2.0.1 copied to clipboard
This package aims to calculate entrophy for plain text passwords, different implementations may have slighty different results from this package.
password_entropy #
This package aims to calculate entrophy for plain text passwords, different implementations may have slighty different results from this package.
To use this package, add password_entropy
as a dependency in your pubspec.yaml file.
List of characteres that are considered valid in this package:
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
You don't need to provide this list, and to check if a password is valid the function validatePassword
can be used as demonstrated in the example bellow.
Example #
import 'package:password_entropy/password_entropy.dart';
void main() {
//Use via extension method
final double? entrophy1 = 'mYpassWord'.passwordEntrophy;
print(entrophy1); // 57.00439718141092
//Will return null for some special characters like '¬' (invalid password)
final double? invalidPass = '(¬_¬)'.passwordEntrophy;
print(invalidPass); // null
//Use via static method
final double? entrophy2 = PasswordEntrophy.entrophy('Password');
print(entrophy2); // 45.60351774512874
// Checking if password is valid
print('(¬_¬)'.validatePassword()); // false
print('(_pasword_)'.validatePassword()); // true
print('(_pasword_)'.validatePassword(minLenght: 20)); // false
//Also can be used as static method
print(
PasswordEntrophy.validatePassword(
'(_pasword_)',
maxLenght: 20,
minLenght: 3,
),
); // true
}