1 Replies - 1708 Views - Last Post: 13 January 2009 - 09:57 AM

#1 KevinADC   User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 401
  • Joined: 23-January 07

Random Password Generator

Posted 23 January 2007 - 10:38 PM

Description: A snippet that can be used in any perl program to generate a random password.
# Call the rand_pass() subroutine from
# anywhere in a perl script to generate
# a random password.

my $password = rand_pass();
# now do something with $password :)

# Place this subroutine anywhere in a perl
# script to pass back a password for use
# as needed. 
 
sub rand_pass {

   # An array of characters used to make the passwords.
   # Lower-case 'L' and the number one '1' as well a
   # lower-case 'O' and the number zero '0' are omitted
   # to avoid confusion between them. Upper-case alpha
   # characters could be added if mixed-case passwords
   # are desired. 
   my @chars = ('a'..'k','m','n','p'..'z','2'..'9');

   # The number of characters to use in passwords
   my $length = 12;

   # Initialize an empty string.
   my $password = '';

   # A loop to get random characters from the array
   # and concatenate them into a password.  
   for (1..$length) {
      $password .= $chars[int rand @chars];
   }

   #return the password back.  
   return $password;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Random Password Generator

#2 souri_sen   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 21-December 08

Re: Random Password Generator

Posted 13 January 2009 - 09:57 AM

I have seen the code. It is really good. But what we need this to encrypt that one. can you send me a code that will encrypt the password on my email id: [email protected]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1