まず、CRYPT_BLOWFISHを使用するには、$2a$で始まる16文字の塩を使用する必要があることがわかります。ただし、crypt()のphp.netドキュメントには、一部のシステムはCRYPT_BLOWFISHをサポートしていないと記載されています。その場合はどのくらいの頻度ですか?
次に、ドキュメントの例から、次のようにcrypt()を使用していることがわかります。
<?php
$password = crypt('mypassword'); // let the salt be automatically generated
/* You should pass the entire results of crypt() as the salt for comparing a
password, to avoid problems when different hashing algorithms are used. (As
it says above, standard DES-based password hashing uses a 2-character salt,
but MD5-based hashing uses 12.) */
if (crypt($user_input, $password) == $password) {
echo "Password verified!";
}
?>
CRYPT_BLOWFISHを使用するために、私が変更する必要があるのは、そのようにするための最初の行だけです。
crypt('mypassword', '$2a$07$usesomesillystringforsalt$')
その後、残りの行はそのままで問題ありませんか?