gpt4 book ai didi

PHP 密码 crypt 给出奇怪的结果

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:33 28 4
gpt4 key购买 nike

我在测试登录时得到了一个奇怪的结果。当我使用密码“100percent”时,显示以下输出

ltu1GUwy71wHk = ltu1GUwy71wHk

如果我使用密码 100percenttest,我会得到相同的输出。

两个不同的密码如何得出相同的结果?

//Get login Details
$username = mysql_real_escape_string($_GET['username']);
$password = mysql_real_escape_string($_GET['password']);
$deviceID = mysql_real_escape_string($_GET['deviceID']);
$model = mysql_real_escape_string($_GET['model']);
$platform = mysql_real_escape_string($_GET['platform']);
$version = mysql_real_escape_string($_GET['version']);
$password = crypt($password, "MYSALT");

//Check login details
$loginQuery = "SELECT * FROM tblMember WHERE Username='$username'";
$loginResult = mysql_query($loginQuery);
$loggedIn = false;
$result = array();
while($row = mysql_fetch_array($loginResult))
{
echo $row['Password'] . "=" . $password . "<BR/>";

最佳答案

来自documentation :

The standard DES-based crypt() returns the salt as the first two characters of the output. It also only uses the first eight characters of str, so longer strings that start with the same eight characters will generate the same result (when the same salt is used).

您可以在 salt 前加上特定的字符串以强制 PHP 使用不同的算法(例如,$5$ 以使用 SHA-256)。我个人建议在高回合数时使用 Blowfish;有关示例,请参阅文档。

附言- 你永远不应该在你的 PHP 代码中使用 mysql。请改用改进的 mysqli 扩展。

关于PHP 密码 crypt 给出奇怪的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18051589/

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