保护密码,Javascript到PHP

时间:2016-11-20 13:22:45

标签: passwords

现在,技术变化更快。你能否告诉我最好的技术来保护联系表格中的密码?

我读到的功能是MD5,SHA1,但我不知道最佳选择。

这个想法是保护Javascript的密码。然后,在PHP中获取值并将其保存在数据库中。

任何推荐? 感谢

1 个答案:

答案 0 :(得分: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);
相关问题