【问题标题】:Protect password, Javascript to PHP保护密码,Javascript 到 PHP
【发布时间】:2016-11-20 13:22:44
【问题描述】:

如今,技术变化更快。你能给我最好的技术来保护密码不被联系表吗?

我读到了 MD5、SHA1 等函数,但我不知道最好的选择是什么。

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

有什么推荐吗? 谢谢

【问题讨论】:

  • 这与 StackOverflow 无关 - 您正在寻求工具/库的建议和意见。没有“最佳”选项。
  • @DavidMakogon 工具/库?惊人的 !!你能推荐我哪个工具?

标签: passwords


【解决方案1】:

密码哈希必须在服务器端完成,客户端哈希可以完成,但永远不能代替服务器端哈希。

使用 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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-20
    • 2016-09-30
    • 2011-05-18
    • 2013-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多