note 93171 deleted from function.crypt by joey
| From: | joey@php.net | Date: | Wed, 03 Apr 2013 20:57:24 +0000 |
| Subject: | note 93171 deleted from function.crypt by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194307@lists.php.net to get a copy of this message | ||
Note Submitter: php at nospam dot nowhere dot com
----
The makesalt() function code below when used to create an MD5 salt, produces a salt with characters
not typically in a salt used by operating system crypt functions. Some of these characters may have
unintended side effects depending on how they are used - including the following: @ ` ~ \ | {}.
I am using the following to create MD5-Crypt hashes, (yes, I am assuming CRYPT_MD5 support is
present).
<?php
function md5crypt($password){
// create a salt that ensures crypt creates an md5 hash
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
.'abcdefghijklmnopqrstuvwxyz0123456789+/';
$salt='$1$';
for($i=0; $i<9; $i++){
$salt.=$base64_alphabet[rand(0,63)];
}
// return the crypt md5 password
return crypt($password,$salt.'$');
}
?>