//A more usefull example for generating SMD5 passwords.
function ldap_smd5_passwd($clear_pw) {
$salt = myhash_keyge_s2k($clear_pw, 4);
$new_password = base64_encode(pack("H*", md5($clear_pw . $salt)) . $salt);
return $new_password ;
}
function myhash_keyge_s2k($pass, $bytes ){
// This and md5 implimentation of the Salted S2K algorithm as
// specified in the OpenPGP document (RFC 2440).
// basically a non mhash dependant version of mhash_keygen_s2k
$salt=substr(pack("h*", md5(mt_rand())), 0, 8);
return substr(pack("H*", md5($salt . $pass)), 0, $bytes);
}
// -ray again.