develooper Front page | perl.beginners | Postings from January 2002

Crypt function explanation

Thread Next
From:
documents
Date:
January 5, 2002 14:59
Subject:
Crypt function explanation
Message ID:
3.0.6.32.20020105200417.008fa100@sbrt.com
Hi, below is a piece of code from the perl man pages.

My question deals with: crypt PLAINTEXT, SALT

Can someone please explain what the SALT is used for, HOW should it be set,
that is,
how many characters long it should be etc.

There is little explanation besides the example in the manual, as well as
on the camel book.

Any advice and extra info is appreciated.

Thank you.

Edgar.

----------------
HereĀ‘s an example that makes sure that whoever runs this program knows
their own password:
$pwd = (getpwuid($<))[1];
$salt = substr($pwd, 0, 2);
system "stty -echo";
print "Password: ";
chop($word = <STDIN>);
print "\n";
system "stty echo";
if (crypt($word, $salt) ne $pwd) {
die "Sorry...\n";
} else {
print "ok\n";
}
-----------------------

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About