note 28002 added to function.crypt

From: Date: Sun, 29 Dec 2002 06:53:19 +0000
Subject: note 28002 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-41409@lists.php.net to get a copy of this message
in response to manfire at softhome dot net: crypt() generates a string which is 34 characters in length. It sounds like you specified a database field which was only 30 characters in length. So while crypt() generated all 34 characters, it only stored 30 in your database, causing problems when you compared the two strings. Here is full sample code for generating and verifying a password: $mypasswd = "gadget"; $hashed = crypt($mypasswd); $chkpass = crypt($mypasswd, $hashed); if ($hashed == $chkpass) { echo "password verified"; } else { echo "password invalid"; }; -- http://www.php.net/manual/en/function.crypt.php http://master.php.net/manage/user-notes.php?action=edit+28002 http://master.php.net/manage/user-notes.php?action=delete+28002 http://master.php.net/manage/user-notes.php?action=reject+28002

« previous php.notes (#41409) next »