Categories: educational, technology
While working on openldap integration using php5.3 I noticed that documentation is lacking on how to create a password hash in SSHA that works in the latest PHP versions. Thought this might help another.
// Generate SSHA hash
mt_srand((double)microtime()*1000000);
$salt = pack("CCCCCCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand());
$cpasswd = "{SSHA}" . base64_encode( sha1( $pass . $salt, true) . $salt );
Now just use $cpasswd in the userPassword