Streamlining of a few character-counting methods regarding suitability of

passphrases.
This commit is contained in:
Drake 2006-11-22 21:32:28 +00:00
parent 567219c767
commit 4da7c74740

View file

@ -30,15 +30,7 @@ sub _hasNonWordCharacters {
my $self = shift;
my $password = shift;
my $numberRequired = shift;
my @characters = split(//,$password);
my $counter = 0;
foreach my $character (@characters) {
$self->session->errorHandler->warn($character);
$counter++ if ($character =~ /\W/);
return 1 if ($counter == $numberRequired);
}
return 0;
return ($password =~ tr/A-Za-z0-9_//c) >= $numberRequired;
}
#-------------------------------------------------------------------
@ -47,13 +39,7 @@ sub _hasNumberCharacters {
my $self = shift;
my $password = shift;
my $numberRequired = shift;
my @characters = split(//,$password);
my $counter = 0;
foreach my $character (@characters) {
$counter++ if ($character =~ /\d/);
return 1 if ($counter == $numberRequired);
}
return 0;
return ($password =~ tr/0-9//) >= $numberRequired;
}
#-------------------------------------------------------------------
@ -62,14 +48,7 @@ sub _hasMixedCaseCharacters {
my $self = shift;
my $password = shift;
my $numberRequired = shift;
my @characters = split(//,$password);
my ($numberOfCaps, $hasLower, $counter);
foreach my $character (@characters) {
$hasLower = 1 if ($character =~ /[a-z]/);
$numberOfCaps++ if ($character =~ /[A-Z]/);
return 1 if ($hasLower && $numberOfCaps == $numberRequired);
}
return 0;
return $password =~ tr/a-z// && ($password =~ tr/A-Z//) >= $numberRequired;
}
#-------------------------------------------------------------------