http://qs321.pair.com?node_id=6136

   1: Good for creating passwords for .htpasswd files or for any other *nix password file:
   2: 
   3: <CODE>
   4: sub mkpasswd{
   5:   my($plaintextpass)=@_;
   6:   my($salt1, $salt, $encrypted);
   7: 
   8:   $salt1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./'; 
   9:   $salt = substr($salt1,rand(length($salt1)),1);
  10:   $salt .= substr($salt1,rand(length($salt1)),1);
  11:   $encrypted = crypt($plaintextpass, $salt);
  12: 
  13:   return $encrypted;
  14: }
  15: </CODE>