Here is a shot.  I am not regex so I was not able to do a single regex for the 
double characters, why I am pretty sure could be done, but not by me. You need to pull

my $MyCnt ;
my %MyCnts = ();
while ( 1 ) {
   printf "Please enter password:";
   chomp(my $MyPasswd = <STDIN>);
   last if ( $MyPasswd =~ /^(qu|ex)$/i );

#
#  Does the double symbols/number check
#
   my $MyDoubles = 0;
   my $MyFirst = '';
   while ( $MyPasswd =~ /(.)/g ) {
       my $MyHit = $1;
       if ( $MyHit eq $MyFirst and $MyFirst =~ /[^a-z]/i ) {
          $MyDoubles++;
          last;
        }
       $MyFirst = $1;
    }
   
   if ( $MyDoubles  ) {
      printf "You have double numbers/symbols in a row\n";
      next;
    }
#
# End of doubles check
#

#
#  Check for at least two symbols/numbers in first 8 bytes
#
   if ( $MyCnt = (substr($MyPasswd,0,8) =~ tr/a-zA-Z//) > 6 ) {
      printf "You must have at least 2 numbers and/or symbols in first 8 characters\n";
      next;
    }
#
# End of symbols/number check must at least 2 in first 8 characters
#

#
#  Counts to have at least 5 different characters in the password
#
   %MyCnts = ();
   foreach ( split(//,$MyPasswd) ) {
     $MyCnts{$_}++;
    }
   if ( scalar(keys %MyCnts) < 5 ) {
                printf "Not enough different characters\n";
        next;
        }
#
# End of at least 5 different characters needed
#
 }
^--------- End of script

Wags ;)
-----Original Message-----
From: Batchelor, Scott [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 20, 2001 11:41
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]

Reply via email to