You are returning a pointer to the decrypted message which is no longer valid:
const char * Client_Side::AES_Decrypt()
{
CkCrypt2 decrypt;
const char * Decrypted_Message2 ;
Decrypted_Message2 = decrypt.decryptStringENC(Enc_Msg2);
return Decrypted_Message2;
}
CkCrypt2
will allocate an internal buffer for the decrypted string which is returned by the decrypt function. When returning from your function, the
CkCrypt2
instance
decrypt
goes out of scope, the destructur is called, and the buffer is released. So the value returned by your function is still pointing to the buffer address but the memory content is undefined.
Also your network transfer is at least suspicious:
How does
socket.receiveString()
detects the end of a received string?
Is
clientSock->SendString()
sending a NULL terminated string or is there some kind of protocol used that contains the string length?