As I understand it, blowfish is generally seen a secure hashing algorithm, even for enterprise use (correct me if I'm wrong). Because of this, I created functions to create and check secure password hashes using this algorithm, and using the (also deemed cryptographically secure) openssl_random_pseudo_bytes function to generate the salt.
<?php
function generate_hash($password, $cost=11){
$salt=substr(base64_encode(openssl_random_pseudo_bytes(17)),0,22);
$salt=str_replace("+",".",$salt);
$param='$'.implode('$',array(
"2y", str_pad($cost,2,"0",STR_PAD_LEFT), $salt ));
return crypt($password,$param);
}
function validate_pw($password, $hash){
return crypt($password, $hash)==$hash;
}
?>