【发布时间】:2017-03-14 18:47:32
【问题描述】:
我有这个功能:
function dec($dec)
{
$ans="";
for($x=0; $x<strlen($dec);$x++)
{
$tempAscii = ord(substr($dec,$x,1)) - ($x+1)*2; //((int)dec[x] - (x+1)*2)
while ($tempAscii <0) $tempAscii+=256;
echo $tempAscii,", ";
$ans = $ans . chr($tempAscii);
}
return $ans;
}
echo "dec, ", dec($_GET['word']);
例如,那些 dec 结果很好:
input: as output: _o middle output: 95, 111
input: SHA256 output: QD;*+* middle output: 81, 68, 59, 42, 43, 42
但是当我尝试这个输入时,我得到了一些奇怪的东西:
input: $@SHA256*!# output: " middle output: 34, 60, 77, 64, 55, 38, 39, 38, 24, 13, 13
我不确定我得到这个输出的原因是因为我在我的函数中犯了一个错误,还是有其他原因。为什么我得到" 作为最后一个结果?谢谢。
编辑:我正在使用 Firefox 查看结果。
编辑:似乎<是问题所在。似乎firefox将其视为“更小”...我怎样才能将其更改为> char而没有任何意义?
【问题讨论】:
-
这是来自控制台的输出还是通过网络浏览器查看? 60 是
<的 ASCII 字符,因此浏览器可能会尝试解释它。 -
@kyeiti 通过火狐浏览器。你是什么意思?我不能在 ascii 中表示
-
@Faraz 我不明白为什么这个问题对我有帮助......