echo crypt("password is not more secure now",CRYPT_BLOWFISH );
echo crypt("i am not secure",CRYPT_STD_DES );// Standard DES-based hash
echo "<br/>";
echo crypt("i am not secure",CRYPT_EXT_DES );// Extended DES-based hash
echo "<br/>";
echo crypt("i am not secure",CRYPT_MD5);//MD5 hashing with a twelve character salt starting with $1$
echo "<br/>";
$key = pack('H*', "bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3");
$plaintext = "This string was AES-256 / CBC / ZeroBytePadding encrypted.";
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
echo $ciphertext = mcrypt_encrypt(MCRYPT_BLOWFISH , $key,
$plaintext, MCRYPT_MODE_CBC,$iv);
$passwordhash=md5("security");
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$options = array('cost' => 11, 'salt' => $iv );
password_hash("security", PASSWORD_BCRYPT, $options)."\n";
function gensalt_blowfish($input)
{
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$iteration_count_log2 = 8;
$output = '$2a$';
$output .= chr(ord('0') + $iteration_count_log2 / 10);
$output .= chr(ord('0') + $iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
echo gensalt_blowfish('testing');