Try this out, it seems to work ok.
my @passwords = ("12threefour", "5six7eight", "9ten9ten9ten", "number1");
for ( @passwords ) {
my $error = checkPass($_);
print ( ($error) ? "$error\n" : "Good pass!\n" );
}
sub checkPass {
my $password = shift;
# reject double nums/symbols
if ( $password =~ /[^a-zA-Z]{2,}/ ) {
return "Double numbers or symbols";
}
# two nus in first eight chars
my $eightchr = substr($password,0,8);
if ( $eightchr !~ /\d\D*\d/ ) {
return "Not enough numbers";
}
# at least 5 different chars
my %chars;
for ( split(//, $password) ) {
$chars{$_}++;
}
if ( scalar(keys %chars) < 5 ) {
return "Not enough different characters";
}
}
-----Original Message-----
From: Batchelor, Scott [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 2:41 PM
To: '[EMAIL PROTECTED]'
Subject: Searching a string?
Hi all,
I am new here. But I need to ask what I hope is a relatively easy question.
I am writing a script that checks a password that someone enters. I have
what can be allowed in the password in and working. But I am also trying to
do a couple of other things.
1. I am trying to not allow doubled numbers or symbols(e.g. 99 or %%)
2. Also want to make it so the password has at least two numbers or
symbols in the first 8 characters.
3. And finally the password must be at least 5 different characters.
Any help would be greatly appreciated. I am sure the answer is out there I
am just under a very tight time constraint.
Thanks
Scott M. Batchelor | [EMAIL PROTECTED]
IT Policy Office - OVPIT | voice: (812) 855-6346
Indiana University | fax: (812) 855-7868
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]