首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >password_hash()在使用ROT13后不会返回任何内容

password_hash()在使用ROT13后不会返回任何内容
EN

Stack Overflow用户
提问于 2022-03-06 19:22:43
回答 1查看 78关注 0票数 0

在我的php文件中,我有3个变量,一个包含清除密码,一个包含ROT13加密反转后的清除密码,还有我的最后一个包含散列密码的变量。

代码语言:javascript
复制
 <?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文件以解释并验证它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-06 20:02:21

$clearpwd$reversedpwd不一样。

尝试将它们与var_dump($clearpwd === $reversedpwd)进行比较。

也许在字符串中的文本周围有一些空格?试试trim($reversedpwd)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71373490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档