我在PHP.net上讀到MD5是無用的,他們建議使用crypt + salt。Crypt和Salt對於暴力攻擊比MD5更安全嗎?
所以,我去他們的功能描述和閱讀
<?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!";
}
?>
或在我的情況是這樣的:
$stored_password=fetch_password($user);
if (crypt($_REQUEST['password'],$stored_password)===$stored_password) {
// ok
}
所以,當我看到鹽存儲在哈希密碼和你使用散列密碼作爲salt,我認爲Crypt + Salt對輸出的蠻力(設法竊取密碼的黑客)並不是更安全。它更安全嗎?
針對字典攻擊,我可以理解它的威力,但是對於哈希密碼的暴力攻擊,我沒有看到優勢。
鹽會幫助反對傳統的暴力攻擊,因爲黑客必須建立一個調整爲鹽的字典。如果使用用戶獨特的鹽,那麼每個用戶都必須擁有自己的字典。 – Zar 2011-12-27 15:54:44
字典不用於傳統的蠻力攻擊。 – MrGlass 2011-12-27 15:58:17