Brothers and sisters with the environment to help run under.
Test data $str1= "1149395524", $str 2 = "4255390370"
Xor
function My_xor ($text, $key)
{
$i = 0;
$encrypted = "";
foreach (Str_split ($text) as $char) {
$encrypted. = Chr (ord ($char) ^ ord ($key {$i + +% strlen ($key)}));
}
return $encrypted;
}
Base64 encode
function My_generate_sign ($str 1, $str 2)
{
$xorstr = My_xor ($str 1, $str 2);
Return Base64_encode ($XORSTR);
}
I wrote Java based on this XOR and Base64 encryption, but the data did not seem the same, trouble with the environment of friends to help me run, by the way to explain the My_xor ($text, $key) method, see if I understand the error.
------to solve the idea----------------------
bqmbdaaabqyfba==
What does Java have?
------to solve the idea----------------------
$text = ' 1149395524 ';
$key = ' 4255390370 ';
$s = My_xor ($text, $key);
echo Base64_encode ($s), php_eol;//requires Base64 encoding because it contains invisible characters. You decode it, you restore it.
Print_r (Unpack (' c* ', $s)); Decimal Inside Code
Xor
function My_xor ($text, $key)
{
$i = 0;
$encrypted = "";
foreach (Str_split ($text) as $char) {
$encrypted. = Chr (ord ($char) ^ ord ($key {$i + +% strlen ($key)}));
}
return $encrypted;
}
bqmbdaaabqyfba==
Array
(
[1] = 5
[2] = 3
[3] = 1
[4] = 12
[5] = 0
[6] = 0
[7] = 5
[8] = 6
[9] = 5
[Ten] + 4
)