我已经获得了这段代码,该代码对给定PHP中键的字符串执行XOR操作。
function xor_encrypt($in, $key) {
$text = $in;
$outText = '';
for($i=0;$i<strlen($text);$i++) {
$outText .= $text[$i] ^ $key[$i % strlen($key)];
}
return $outText;
}
... which produces qw8Jqw8Jqw8Jqw8Jqw8Jqw8Jqw8Jqw8Jqw8Jqw8Jq
for one of the inputs and given cipher text, but the actual output should be qw8J
. I'm wondering if someone here can help me understand why the pattern repeats.