[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Password



At 20.54 12/15/97, Len wrote:
>I would like to be able to add to a password file via Perl. I assume this
>can be done using the htpasswd command. Can anyone help me with some script?

Perl has no htpasswd command.  And what kind of passwords are we talking?

If you want encrypted passwords, check out the crypt() function.

Here is an example modified from the MacPerl documentation (perlfunc.pod):

$pwd = crypt('mypassword',rand(time));
$salt = substr($pwd, 0, 2);

print "Password: ";
chop($word = <STDIN>);
print "\n";

if (crypt($word, $salt) ne $pwd) {
  die "Sorry...\n";
} else {
  print "ok\n";
}

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch