Un simple generador de contraseñas
Imagen
(http://doddyhackman.webcindario.com/images/gen.jpg)
#!usr/bin/perl
#Gen Password (C) Doddy Hackman 2011
use Tk;
if ($^O eq 'MSWin32') {
use Win32::Console;
Win32::Console::Free();
}
my $sin = MainWindow->new();
$sin->title("Gen Password (C) Doddy Hackman 2011");
$sin->geometry("530x80+20+20");
$sin->resizable(0,0);
$sin->Label(-text=>"Result : ",-font=>"Impact1")->place(-x=>30,-y=>20);
my $rex = $sin->Text(-width=>28,-height=>1)->place(-y=>24,-x=>90);
$sin->Label(-text=>"Length : ",-font=>"Impact1")->place(-x=>310,-y=>20);
my $leng = $sin->Entry(-width=>3,-text=>3)->place(-y=>24,-x=>370);
$sin->Button(-text=>"Generate",-command=>\&gen,-width=>12)->place(-y=>22,-x=>410);
MainLoop;
sub gen {
$rex->delete("0.0","end");
my $ala = $leng->get;
my @password = genpass($ala);
for $pass(@password) {
$rex->insert("end",$pass);
}}
sub genpass {
my $length = shift;
my @re;
my @mayus = (A..Z);
my @minus = (a..z);
my @number = (0..9);
my @op = (1..3);
for (1..$length) {
my $opt = @op[rand(@op)];
if ($opt eq 1) {
push(@re,@mayus[rand(@mayus)]);
}
elsif ($opt eq 2) {
push(@re,@minus[rand(@minus)]);
}
elsif ($opt eq 3) {
push(@re,@number[rand(@number)]);
}
}
return @re;
}
#Thanks to explorer (perlenespanol)
# ¿ The End ?