Title: RE: Terrible at my logic

sub GenRandomPW ($Length)

{

    # This subroutine generate a relatively strong random password of a specified length.

    &WriteLog($LogFile, "Entered GenRandomPW") if $DEBUG;

 

    my $Length = shift;

 

    my $password;

    my @chars = ('A'..'H', 'K', 'M', 'N', 'P'..'R', 'T'..'Y', '!', '@', '#', '$', '%', '&', '*', 2..9, 'a'..'h', 'k', 'm', 'n', 'p'..'z');

    my $j = 0;

    while ($j<3)

    {

        $password = "";

        my $i;

        for ($i=1;$i<=$Length; $i++)

        {

            $password .= @chars [rand (scalar @chars)];

        }

        $j = 0;

        if ($password =~ /[A-Z]+/) { $j++; }

        if ($password =~ /[0-9]+/) { $j++; }

        if ($password =~ /[a-z]+/) { $j++; }

        if ($password =~ /[!@#\$%&\*]+/) { $j++; }

    }

    return $password;

}

 

 

-----Original Message-----
From: Patrick Connolly [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, October 29, 2002 1:08 PM
To: '
Krishna, Hari'; 'FARRINGTON, RYAN'; [EMAIL PROTECTED]
Subject: RE: Random numbers

 

To make it even a little more fun you could also vary the length of the password:

 

@a = (0..9,A..Z,a..z);          # password charactors

@b = (6..14);                      # length of password

for($I=0;$I<1000;$I++) {

   for($x=0;$x<$b[rand @b];$x++) {

      print $a[rand @a];

   }

   print "\n";

}

-----Original Message-----
From: Patrick Connolly [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, October 29, 2002 1:00 PM
To: '
Krishna, Hari'; 'FARRINGTON, RYAN'; '[EMAIL PROTECTED]'
Subject: RE: Random numbers

 

@a = (0..9,A..Z,a..z);

for($I=0;$I<1000;$I++) {

   for($x=0;$x<8;$x++) {

      $index   = rand @a;

      print $a[$index];

   }

   print "\n";

}

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Krishna, Hari
Sent:
Tuesday, October 29, 2002 12:48 PM
To: 'FARRINGTON, RYAN'; [EMAIL PROTECTED]
Subject: Random numbers

 

Hi friends,

    I want to generate some 1000 or more passwords for some NT machine.

I should be able to generate an 8 digit alphanumeric random numbers from the list of characters.

 

Say I have 3 strings...

First string : 0 - 9 numbers

Second string : A - Z characters

Third string: a - z characters.

 

Now I should be able to generate strings like:

 

"abCd16Sz"

"U8Yb90vc"

"Nt7gO0PL"

 

something like that.

 

Is there a way to generate such kind of random numbers 8 characters long???

 

I saw in a bok that there is a module in PERL

MATH::TrulyRandom

 

but I am not sure if it helps. I will keep trying.

 

 

any inputs appreciated.

 

Hope I can get some help.

 

 

Thanks and Regards,

Hari.

Reply via email to