note 30865 deleted from function.crypt by aidan
| From: | aidan@php.net | Date: | Mon, 05 Jul 2004 10:28:26 +0000 |
| Subject: | note 30865 deleted from function.crypt by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72588@lists.php.net to get a copy of this message | ||
Note Submitter: sqlboy@playway.net
----
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;
}