NAME

Data::Password::Meter - Check the strength of passwords

SYNOPSIS

my $pwdm = Data::Password::Meter->new(28);

# Check a password
if ($pwdm->strong('s3cur3-p4ssw0rd')) {
  print "The password is strong enough!\n";
  print 'Scored ' . $pwdm->score . ' points!';
}
else {
  warn $pwdm->errstr;
};

DESCRIPTION

Check the strength of a password. The scoring is based on Passwordmeter by Steve Moitozo.

ATTRIBUTES

err

print $pwdm->err;

The error code of the last check. Returns a false value, if the last check was successful.

errstr

print $pwdm->errstr;
print $pwdm->errstr(4);

The error string of the last check, or, in case an error code is passed, the corresponding message. Returns an empty string, if the last check was successful.

score

print $pwdm->score;

The score of the last check.

threshold

print $pwdm->threshold;
$pwdm->threshold(28);

The scoring threshold, the determining factor when a password is too weak. Every password that is below this threshold is considered weak. Defaults to a score of 25.

METHODS

new

my $pwd = Data::Password::Meter->new(28);

Constructs a new password check object. Accepts an optional value for the threshold.

strong

if ($pwdm->strong('mypassword')) {
  print 'This password is strong!';
}
else {
  print 'This password is weak!';
};

Checks a password for strength. Returns a false value in case the password is considered to be weak.

ERROR MESSAGES

Possible error codes and strings are:

  • 1. There is no password given

  • 2. Passwords are not allowed to contain control sequences

  • 3. Passwords are not allowed to consist of repeating characters only

  • 4. The password is too short

  • 5. The password should contain special characters

  • 6. The password should contain combinations of letters, numbers and special characters

  • 7. The password is too short and should contain special characters

  • 8. The password is too short and should contain combinations of letters, numbers and special characters

  • 9. The password should contain special characters and should contain combinations of letters, numbers and special characters

  • 10. The password is too short, should contain special characters and should contain combinations of letters, numbers and special characters

DEPENDENCIES

No dependencies other than core.

AVAILABILITY

https://github.com/Akron/Data-Password-Meter

COPYRIGHT AND LICENSE

Copyright (C) 2006, Steve Moitozo, (C) 2013-2021, Nils Diewald.

Licensed under the MIT License