my goal would be to create an encrypted communication between a client and server
c strings and std::string use the null terminating character as the end of the string. when encryption is done, there may be a chance that it encrypts a char to a '\0' and the string prematurely terminates.
My friend told me that it would be best to convert each char in the string to a hex number, perform the encryption on that number and then concatenate the number as a string to send it across the network. The server side would then parse the string containing hex numbers into chars once again to reconstruct the original string.
How would I go about doing the conversion from char to hex and then hex back to char?
thanks to master roshi but would doing my original way compromise the confidentiality of my message since the length is sent in plaintext or do I encrypt the length too?
There are other tricks you could also do for increased protection. Depending on the size of the message, you could split it in parts and send it with the following format:
thanks, but as for the solution for converting the original string to the hex string you gave, how do I convert the hex string back to the original string?