note 33452 deleted from function.crypt by aidan

From: Date: Mon, 05 Jul 2004 10:29:25 +0000
Subject: note 33452 deleted from function.crypt by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72595@lists.php.net to get a copy of this message
Note Submitter: mimec@wp.pl ---- If your server only supports simple DES-based encryption, and you want to encrypt passwords with the MD5 algorithm and use a random salt, you may use the following function: function crypt_md5($str, $salt=null) { if (!$salt) $salt = md5(uniqid(rand(), 1)); $salt = substr($salt, 0, 8); return $salt . ":" . md5($salt . $str); } It can be used similarly to the crypt() function, i.e.: $crypted_pass = crypt_md5($password); if (crypt_md5($verified_pass, $crypted_pass) == $crypted_pass) { // correct password } Note that this function does not generate the same result as crypt() with the MD5 support.

« previous php.notes (#72595) next »