SRL Archive - Web Development

Random Passwords [Perl]


Harry

2009-10-11 21:57:51

http://harryy.us/files/passwd.pl

Source:
#!/usr/bin/perl

srand($$|time);
$ascii_passwd = &pw_generate;

sub pw_generate {
local(@passset, $rnd_passwd, $randum_num);
local($randum_num);

@passset = ('a'..'k', 'm'..'z', 'A'..'N', 'P'..'Z', '2'..'9');
$rnd_passwd = "";
for ($i = 0; $i < 30; $i++) {
$randum_num = int(rand($#passset + 1));
$rnd_passwd .= @passset[$randum_num];
}
return $rnd_passwd;
}

{
print "Content-Type: text/html", "\n\n";
print "Hi, here is your random password:<b> ",$ascii_passwd, " </b>...keep it safe!\n";
}

It has a lot of entropy, in my opinion. Any suggestions on what I should/could change?

EvilChicken!

2009-10-12 03:40:51

Hm, interesting. I don't know Perl myself, but the syntax is understandable to me.

You could make this into a random ID/personalia generator?

Harry

2009-10-12 03:59:54

Yeah, I suppose you could; it is just a simple pseudo-random Perl string creator :)

cycrosism

2009-10-12 05:05:25

cool script bro