4
首先,我看到要使用CRYPT_BLOWFISH,我需要用$ 2a $開頭的16個字符的鹽。但php.net documentation for crypt()表示某些系統不支持CRYPT_BLOWFISH。這種情況多久?(PHP)如何在CRYPT_BLOWFISH中使用crypt()?
接下來,他們對文檔的例子,我看到我用的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$')
然後其餘的行都很好嗎?
是的,但只有我離開的問題是:當我創建的密碼,我使用的crypt( '輸入mypassword', '$ 2A $ $ 07 usesomesillystringforsalt $'),對不對?我的鹽實際上是一個隨機生成的16個字符串? – sepiroth 2010-02-10 11:23:19