|I tried to comment the crypt/decrypt and so, the full text is clear, so the problem comes from my crypt/decrypt algo.|
1. So you don't have bugs when you send and receive plain BIG text, only when send text crypt/decrypt?
|I don't know why I receive it in two part|
2. This fragmentation is not matter when you can correctly restore the entire message from these fragments. As I know(but as I said, I don't know even the shit about socket programming) the stream protocol can fragment messages any way it likes
3. If you sure that plain text messages are OK, tell me here and I will tell you how we will proceed. I'll find your bug if I know that it is not something happen in "socket" during send-recv process.
P.s. I can tell almost sure what the nature of bug is, but this almost is not 100%
First, you receive message on two parts with different sizes depending from sending protocol.
Second, you combine them together to make messageOriginal
Third, if the message1 have "\0" end on it when you combine message1+message2 = messageOriginal - if the text is PLAIN, nothing will happen, simply messageOriginal will be with one byte bigger(or two byte, if and message2 have null character end too). (You don't see Null character in the middle if look messageOriginal with plain text). But when you decrypt this messageOriginal (with one byte bigger) your decrypt will be correct exactly to the end of message1 where "\0" is added. Next decrypt will not work because first KEY will act on "\0", not on begin symbol from message2. Rest of text will be mess because you "shift" decrypt keys on second half of the messageOriginal so it will act more like crypt algo. This not mean that your decrypt algorithm don't work.
Fourth, sometimes you have correct decrypt because transfer protocol DON'T split send message on two fragment, but send it in one.
But as I said it is only theory.
P.p.s. Use test keys only from 00000000 instead 49523851. "a,b,c,d,e" becomes "a+0,b+0,c+0,d+0,e+0". In this way you will see if there is problems in your crypt/decrypt code, because as I suggest, the problem probably is not in them. They will not do nothing, and text will stay plain (am I worng?).
|I tried to set my keys to 0, and so it works in this case.|
So it is not decrypt part.
|I tried to avoid the '\0' by adding one to my char if it was null. But still not working.|
I don't understand where you add one char - but this is not the solution - you must extract char instead if such is added because if it is in the middle it will shift decrypt keys for second part of the message.
P.p.p.p.s Many developers first they try to look for the problem in the code, before understand the bug itself. Don't act in this way! First analyses the bug, next look in the code. So far there has not been a bug that has occurred and I can not find it :-) I have not even looked at your code yet. If you are cooperative, things will get faster.