【发布时间】:2021-11-27 14:11:32
【问题描述】:
本地尝试使用给定密码解密二进制文件。数据以十六进制的 0A 分隔。在解密阶段,我的数组就像一个 int,我不知道为什么。有没有合适的解决办法?
-
php版本:8.0.11
-
试图重新安装 xampp
-
尝试过的铸件
<?php if(count($_POST)>0) { $ciper = array(5, -14, 31, -9, 3); $dec_arr = []; $ind = 0; $handle = fopen("secret.txt", "r"); if ($handle) { while (!feof($handle)) { $hex = bin2hex(fread ($handle , 1 )); $dec_arr[$ind] = hexdec($hex); $ind++; } fclose($handle); } unset($dec_arr[(count($dec_arr)-1)]); $raw_data = ""; for($i = 0, $k = 0; $i < count($dec_arr); $i++)//Warning: Trying to access array offset on value of type int { if($dec_arr[$i]==10) { $dec_arr[$i] = 59; $k = 0; } else { $dec_arr = ((($dec_arr[$i] + 256) - $ciper[$k])%256);//Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given } $raw_data .= chr($dec_arr[$i]); $k = (($k+1)%5); } }?>
【问题讨论】:
-
$dec_arr = ((($dec_arr[$i] + 256) - $ciper[$k])%256);您正在将$dec_arr从数组更改为数字。这将导致循环的任何后续迭代失败 -
谢谢@aynber!现在很清楚了。