PHP (md5) 空结果
我的代码示例有问题,结果是空白页。我检查了php中的mcrypt_ecb函数,并且可用。那为什么我只得到空结果?
$suma='9990';
$idobj='38';
$cislooz='TEST';
$input=$suma.$idobj.$cislooz;
$key='KEY';
$encrypted_text = mcrypt_ecb(MCRYPT_3DES, $key, substr(sha1($input),0,8), MCRYPT_ENCRYPT,substr(sha1($input),0,8));
echo "<b>INPUT: </b>".$input."<br>";
echo "<b>KEY: </b>".$key."<br>";
echo "<b>Hash sha1: </b>".substr(sha1($input),0,8)."<br>";
echo "<b>Hash to 3DES/ECB/NoPadding:</b> ".( $encrypted_text )."<br>";
echo "<b>to HEX:</b> ".StrToUpper(bin2hex($encrypted_text))."<hr>";
?>
I have a problem with this code sample, the result is a blank page. I checked mcrypt_ecb function in php, and is available. Then why I got only empty result?
$suma='9990';
$idobj='38';
$cislooz='TEST';
$input=$suma.$idobj.$cislooz;
$key='KEY';
$encrypted_text = mcrypt_ecb(MCRYPT_3DES, $key, substr(sha1($input),0,8), MCRYPT_ENCRYPT,substr(sha1($input),0,8));
echo "<b>INPUT: </b>".$input."<br>";
echo "<b>KEY: </b>".$key."<br>";
echo "<b>Hash sha1: </b>".substr(sha1($input),0,8)."<br>";
echo "<b>Hash to 3DES/ECB/NoPadding:</b> ".( $encrypted_text )."<br>";
echo "<b>to HEX:</b> ".StrToUpper(bin2hex($encrypted_text))."<hr>";
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能在某个地方遇到了问题。我在 PHP 5.3.0 上测试了它,它输出:
您可能触发了 PHP 错误,但知道这一点的唯一方法是
在脚本顶部设置: 以便您能够看到错误是什么。
另一个解释是您使用 ob_start() 启动了一个输出缓冲区,并且您可能管理错误。
或者你可以在某个地方有一个
exit;
或die();
。正如您所看到的,您的问题可能有很多“因为”。
编辑:
最后,我们终于发现了真正的问题。他的代码中的空格被转换为错误的不可见字符;那是因为它是从 PDF 复制的。
这里你可以看到:第一行工作正常,空格对应于
.
中脚本。另一个符号(注释的绿线)导致了问题。You are probably experiencing a problem somewhere. I tested it on PHP 5.3.0 and it output:
You may have a PHP error triggered but the only way to know that is to set:
At the top of your script so that you'll be able to see what the error is.
Another explain is that you started an output buffer with
ob_start()
and you might be managing it wrong.Or you could have an
exit;
ordie();
somewhere.As you can see there might be a lot of "because" for your question.
Edit:
Finally, at last we discovered the real problem. The spaces in his code where converted to the wrong invisible character; that's because it was copied from a PDF.
Here you can see: the first lines works fine and the space correspond to
.
in the script. The other symbol instead (of the commented green lines) was causing the problem.