From e71965beff694bc98c9ae45ee14f91c321298f5b Mon Sep 17 00:00:00 2001 From: Roderick Schertler Date: Wed, 9 Sep 1998 20:32:17 -0400 Subject: [PATCH] doc update for crypt()'s salt Message-ID: <21142.905401937@eeyore.ibcinc.com> p4raw-id: //depot/perl@1846 --- pod/perlfunc.pod | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 2d7b251..b20981d 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -675,19 +675,25 @@ eggs to make an omelette. There is no (known) corresponding decrypt function. As a result, this function isn't all that useful for cryptography. (For that, see your nearby CPAN mirror.) +When verifying an existing encrypted string you should use the encrypted +text as the salt (like C). This +allows your code to work with the standard C and with more +exotic implementations. When choosing a new salt create a random two +character string whose characters come from the set C<[./0-9A-Za-z]> +(like C). + 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 = ); + chomp($word = ); print "\n"; system "stty echo"; - if (crypt($word, $salt) ne $pwd) { + if (crypt($word, $pwd) ne $pwd) { die "Sorry...\n"; } else { print "ok\n"; -- 2.7.4