0
<?php
date_default_timezone_set('Asia/Kolkata');
$xmlfile='xml/adminpwd.xml';
$xml = simplexml_load_file($xmlfile);
if (!empty($_POST['password'])) {
extract($_POST);
if($adminpwd!='this')
$error="Incorrect Password. Enter the correct password.";
}
?>
<form method='post' action='' name='admin'>
<h3 style="color: #798196;">Enter Current Password</h3><br/>
<input type='password' name='adminpwd' />
<input type='submit' name='password' value='Enter'>
</form>
这是我的脚本。php hash()与sha512显示不同的结果相同的值
当我试试这个:
<?php
if (isset($error))
echo "<br/><h3 class='error'>".hash('sha512', $adminpwd)."</h3><br/>";
?>
我得到的输出: de784a6d81e125ff2223d977683c3efdd4513941d3737861008b8358d10e8d2757963c3a2619d0924a70d0e11b53492847f741af6e767388fd395c170508d795
但是当我尝试这个办法:
<?php
if (isset($error))
echo "<br/><h3 class='error'>".hash('sha512', $_POST['adminpwd'])."</h3><br/>";
?>
我得到的输出: 1fc286c9c7dc733b3a46a21a923c646c14c19bac951d63380ec8d4b3c6786fdbe7dd4bd325eef31553fa829e19989fe060da01921cfc68f7b9ff03383f78710b
虽然这两个变量包含相同的字符串。为什么产量不同?
只需在两种情况下输出'$ adminpwd'。你不知道*他们是一样的,直到你看到他们两个。还要注意,前导/尾随空格也是可疑的。 –
这里的好处↑↑↑务必修剪输入的文字。 – MightyPork
两次我输入相同的密码。并重复实验5次以上确认。但结果是一样的。 当我现在尝试,两种情况下给出相同的输出。没有解决问题。但是谢谢。 – RatDon