Receiving all the message...

Hello,

I'm working in an application which encrypts a chain (std::string) and sends it to another by a socket using the operator (<<).

In fact, this other application sometimes fails because doesn't receive all the encrypted string (a std::string, also... and using (>>), too) from the sender first application.

What do you think about ?. Could manage better ?.

S.
If your encryption results in char zero being placed in the string, it may be interpretted as an end of string by some functions. You should encrypt to unsigned char buffers. That way it will be clear to the compiler and readers of your code what you mean.
I think Kbw has it - sometimes encryption will result in non-ASCII values.

To avoid this problem, you must output something like hex. You encrypt, and then encode the result into something like 92957c57a0b (hex) to transmit. Then at the receiving end you take the hex repersentation of the data, and convert it back to characters, or whatever...

A very common problem in cryptography.

"Zero" has special meaning in C strings. You can avoid it by not using strings, but raqther arrays.

Ron.
Topic archived. No new replies allowed.