I try to write simple xor encryption
in PHP 5
. But I can't see the result of xor
operation. For example,
$s1="abcd";
$s2="efgh";
$res1 = $s1 ^ $s2;
$res2 = $res1 ^ $s2;
echo $res1, $res2;
displays $res2
, but $res1
isn't showed. I tried to do this encryption separately for each char in string, but I got same result. As I understood, in real situation, the key and the result must to be HEX-strings
.
But I can't see $res1
as HEX-number
using printf
. Maybe, I need to pack("H*",...) s1
and s2
strings
before using XOR
, but then I can't correctly unpack results (as text string and hex-number respectively).