gpt4 book ai didi

php - MySQL 和 PHP - 密码比较

转载 作者:行者123 更新时间:2023-11-29 12:49:35 26 4
gpt4 key购买 nike

我正在使用存储过程来检查登录尝试时的用户名和密码。 - 密码使用MySQL中的password()函数存储。

并且登录工作正常,使用存储过程,问题是我有一个允许用户更改密码的功能,我应该如何更新它?通过 PHP 实现 MD5?或者我应该构建一个新的存储过程?

谢谢:)

最佳答案

您不应该使用 PASSWORD() 函数作为应用程序级密码。

http://dev.mysql.com/doc/refman/5.6/en/encryption-functions.html#function_password说:

Note
The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. For that purpose, consider MD5() or SHA2() instead. Also see RFC 2195, section 2 (Challenge-Response Authentication Mechanism (CRAM)), for more information about handling passwords and authentication securely in your applications.

如果您使用 SHA2 等标准加密哈希方法,则可以使用 hash extension 在 PHP 中执行哈希。 。 PHP中使用相同算法计算出的哈希值与MySQL中计算出的哈希值是兼容的。

关于php - MySQL 和 PHP - 密码比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24968340/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com