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-----
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-----
@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-----
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. |
Title: RE: Terrible at my logic
- Random numbers Krishna, Hari
- RE: Random numbers Patrick Connolly
- RE: Random numbers Burak Gürsoy
- RE: Random numbers Stovall, Adrian M.
- RE: Random numbers Peter Eisengrein
- RE: Random numbers Patrick Connolly
- RE: Random numbers Krishna, Hari
- RE: Random numbers Bullock, Howard A.
- RE: Random numbers Thomas_M
- Random Numbers Jarrett Malone
- Re: Random Numbers Jenda Krynicky
- Re: Random Numbers Keith C. Ivey