I need to send an encrypted data through a socket in C. So I make my payload like:
message_type|flags|message_1|message_2
I want to encrypt the message_x
with AES.
For security concerns, I need to keep the message_x
length for the ciphertext. That's why I am using the OpenSSL AES-CTR mode.
But there's the problem. The output is completely awful, like �3Y������ȳ�_�[��. And there are characters like [
, _
, etc. Every character could appear in the output. So the receiver won't be able to unserialize the payload because, perhaps, the delimiter (|
in the example) has been generated by AES...
I saw base64
conversion could do the trick. But the conversion changes the length of the ciphertext (like explained in this article).
Does anyone have any ideas ?