I don't know it can or not to post this type of question::
my game server use the following code to encrypt the message and send to client ( This code are not code by me )
std::string EncryptGamePacket(string str)
{
std::string encrypted_string;
std::vector<std::string> buffer;
buffer = split(str, ' ');
encrypted_string += buffer[0].length();
for (int i = 0 ; i < str.length(); i++)
{
if (i == buffer[0].length())
{
int size = str.length() - buffer[0].length();
encrypted_string += size;
}
encrypted_string += str[i] ^ 0xFF;
}
return encrypted_string += 0xFF;
}
And I found that if the str length bigger than 128, the client will receive the wrong message, Anyone know how to solve this problem
Here's two examples:
Success Example (length:127 message):
Server sent Message:
11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 111111111111111111111111111
Client receive Message:
11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 111111111111111111111111111
Incorrect Example (length:128 message):
Server sent Message:
11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 1111111111111111111111111111
Client receive Message:
88888888888888888888888888888888888888888888888888 88888888888888888888888888888888888888888888888888 8888888888888888888888888888
Anyone know about this problem?
I try my best but I can't solve this. Hope anyone can help!!!