I need to XOR a string/text in PHP the base64 encode it, but something goes wrong:
$mustget = 'Kw4SCQ==';
$key = 'frtkj';
$key_length = strlen($key);
$encoded_data = base64_decode($mustget);
$result = '';
$length = strlen($encoded_data);
for ($i = 0; $i < $length; $i++) {
$tmp = $encoded_data[$i];
for ($j = 0; $j < $key_length; $j++) {
$tmp = chr(ord($tmp) ^ ord($key[$j]));
}
$result .= $tmp;
}
echo $result; // Josh
http://ideone.com/NSIe7K
I'm sure you can reverse it and create a function, that "crypts" the data ;-)