Random Password Generator

KevinADC -1 Tallied Votes 426 Views Share

Code snippet to generate random passwords. Avoids using confusing characters such as lower case L (l) and the number one (1), the letter 'O' and the number zero. Upper-case alpha characters could be added to the character set if mixed-case passwords are desired.

my $password = rand_pass();

sub rand_pass {
   my @chars = ('a'..'k','m','n','p'..'z','2'..'9');
   my $length = 7;
   my $password = '';
   for (0..$length) {
      $password .= $chars[int rand @chars];
   }
   return $password;
}
Prakash_8111 0 Newbie Poster

Thanks guys :
I thought one idea :
my $rand=int rand(100*100000);

How it would be ?????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.