在我的php文件中,我有3个变量,一个包含清除密码,一个包含ROT13加密反转后的清除密码,还有我的最后一个包含散列密码的变量。
<?php
$clearpwd = $_POST['var1']; //the password. note that this is not present here just doing this to compare values for the time until the error is solved (lets say that here the value is **something** for example)
$reversedpwd = str_rot13($_POST['var2']); //reversedpwd holds the password given by another site that encrypted previously the password in ROT13
$hashedpwd = '$2y$10$4sIma.5gA9sqoXckMG.Fru/hRxvV6nrodiI/24wvu.qp1jpLG1gU2';
//a hash given by password_hash(something, PASSWORD_DEFAULT); note that the hash is already generated and not regenerated each time you execute the php so it's static.
echo password_verify($clearpwd, $hashedpwd); //returns 1
echo password_verify($reversedpwd, $hashedpwd); //returns nothing
?>因此,当我在末尾执行password_verify时,clearpwd和reversedpwd都保存着完全相同的文本(本例中的“东西”),但只有在清除end时才能得到1。
你知道吗,或者为什么它不喜欢匹配这个算法--一个先前被rot13编码的文本,然后解码成原始字符串(‘东西’)?
其他信息:我使用的是php 7.4和Softaculous。rot13编码的变量来自一个输入,该输入已经使用带有php函数的rot13加密,然后被发送到另一个php文件以解释并验证它。

发布于 2022-03-06 20:02:21
$clearpwd和$reversedpwd不一样。
尝试将它们与var_dump($clearpwd === $reversedpwd)进行比较。
也许在字符串中的文本周围有一些空格?试试trim($reversedpwd)。
https://stackoverflow.com/questions/71373490
复制相似问题