2016-11-20 31 views
-2

Nowdays,技術變化比較快。你能否給我最好的技術來保護聯繫表格中的密碼?保護密碼,javascript傳送給PHP

我讀功能MD5,SHA1,但我不知道什麼是最好的選擇。

的想法是保護密碼從Javascript。然後,在PHP中獲得價值並將其保存在數據庫中。

任何recomendations? 感謝

+0

這是StackOverflow的主題 - 您要求提供工具/庫的建議和意見。沒有「最佳」選項。 –

+0

@DavidMakogon工具/庫?真棒!你可以推薦我哪個工具? – Gregory

回答

0

密碼散列必須做服務器端,客戶端的散列可以做到的,但絕不代替服務器端的散列。

使用PHP,你應該使用功能password_hash(),目前它使用BCrypt算法。切勿使用MD5或SHA- *來哈希密碼,這些算法速度太快,而且可能太容易被粗暴對待。

// Hash a new password for storing in the database. 
// The function automatically generates a cryptographically safe salt. 
$hashToStoreInDb = password_hash($password, PASSWORD_DEFAULT); 

// Check if the hash of the entered login password, matches the stored hash. 
// The salt and the cost factor will be extracted from $existingHashFromDb. 
$isPasswordCorrect = password_verify($password, $existingHashFromDb); 
+0

非常感謝。我感謝您的幫助。真棒。 – Gregory