Answer the question
In order to leave comments, you need to log in
How to decrypt in PHP what was encrypted in UTF16?
There is an encryption received by a simple XOR:
public class HelloWorld {
public static void main(String[] args)
{
String tmp=xorxor("Проверка","keyyek");
System.out.println(tmp);
System.out.println(xorxor(tmp,"keyyek"));
}
public static String xorxor(String str, String key) {
StringBuilder crypt = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
int xor=str.charAt(i) ^ key.charAt(i % key.length());
crypt.append((char) xor);
}
String result = crypt.toString();
return result;
}
}
$string="Проверка";
echo xorxor($string,'keyyek');
function xorxor($string,$key){
$res='';
for($i=0;$i<mb_strlen($string);$i++){
$part1=mb_substr($string,$i,1);
$part2=mb_substr($key, $i % mb_strlen($key),1);
$res.= $part1 ^ $part2;
}
return $res;
}
Answer the question
In order to leave comments, you need to log in
Taki found a way, it still needs to be combed, but it works:
$res .= html_entity_decode("&#".(mb_ord($part1) ^ mb_ord($part2)).";");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question