我正在玩密码加密,当我将密码写入数据库以及当我登录到页面时遇到了一些麻烦。使用sha256密码问题
当我插入密码:
$pword = "huuhaa";
$uname = "huuhaa";
$pword = hash('sha256' ,'$pword');
$insuser="INSERT INTO words(username,password) VALUES('$uname','$pword') ";
$insresult=mysql_query($insuser);
在日志中:
$myusername= 'huuhaa';
$mypassword = 'huuhaa';
$mypasswordCRYPTED = hash('sha256' ,'$mypassword');
$sql="SELECT userid FROM words WHERE username='$myusername' and password='$mypasswordCRYPTED'";
登录:
在数据库中的值是从登录例如值不同。 $ pword在数据库中:e5f252f ...并在登录:$ mypasswordCRYPTED = as89dw ....
有人请给我解释一下吗?
谢谢
该死的jon,你快2秒:(好工作 – genesis
PHP在双引号字符串中插入,而不是单引号字符串,该字符串实际上是“$ pword” – Phil
@Phil:Thanks。Will update。(It's明显更清楚,不要打扰插值无论如何。) –