-1

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;
}
2
Contributors
1
Reply
4
Views
11 Years
Discussion Span
Last Post by Prakash_8111
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.