1

I am using cURL and Microsoft SEAL in C++. I need to serialize a Ciphertext object to send it to a server through a POST request.

The Ciphertext object is serialized into a stringstream but, in order to send it, I need to convert it to a const char*. The problem is that, initially, the string obtained from the stringstream is 88500 chars long (approx.); but, when converted to const char*, it is reduced to 6.

Could the 7th character be '\0', so it is detected as the end of the string? (Both .c_str() and .data() return the same result.)

stringstream st;
cipheredAspirineList[0].save(st);
simplePost("postSingleCipheredAspirine", st.str().c_str());
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
dsimog01
  • 75
  • 1
  • 5
  • what is `st.str().size();`? Worth knowing in case the problem is actually earlier than you think. – user4581301 Dec 01 '21 at 23:02
  • I have found that there are '\0' characters in the string, so that is why the conversion to const char* is wrong. My idea is to replace all '\0' for another char, but I do not know which to use, because it must be one that does not belong to the original string. I have checked that, after replacing all '\0' I get the full length string. Now, I am trying to find an unused "temporary" char, in order to rebuild the original string in the server. – dsimog01 Dec 02 '21 at 12:50
  • Might be a better idea to go base64 encoding or use something smarter than the, making assumption based on the name here, simple `simplePost`. – user4581301 Dec 02 '21 at 17:43
  • Yesterday, some time before you post your comment I came up with the idea of using the base64 and, even though, the string becomes longer, it worked. By the way, simplePost uses curl library. Thanks for the help – dsimog01 Dec 04 '21 at 01:54

0 Answers0