note 30865 added to function.crypt

From: Date: Tue, 01 Apr 2003 15:22:07 +0000
Subject: note 30865 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-46084@lists.php.net to get a copy of this message
function for specifying what crypt to use. Defaults to DES. For your own enjoyment, add blowfish and DES_EXT support or make it auto detect the strongest crypt available. Use like so; define("_SALT_","MD5"); $crypted_pass = crypt($plainText,salt()); function salt() { $prefix = ""; if(_SALT_ == "DES" && CRYPT_STD_DES == 1) { $length = 2; } elseif(_SALT_ == "MD5" && CRYPT_MD5 == 1) { $length = 9; $prefix = "$1$"; } else { $length = 2; } $salt = ""; for($x=0;$x<$length;$x++) { $salt .= substr(crypt(rand(1,65536)),3,1); } return $prefix . $salt; } -- http://www.php.net/manual/en/function.crypt.php http://master.php.net/manage/user-notes.php?action=edit+30865 http://master.php.net/manage/user-notes.php?action=delete+30865 http://master.php.net/manage/user-notes.php?action=reject+30865

« previous php.notes (#46084) next »