The best way to hide a string in binary code in C++?

C++Server Side ProgrammingProgramming

Here we will see how to hide some string into some binary code (Here binary code is represented in hexadecimal number).

The approach is very simple. We can use the string stream to convert decimal number to hexadecimal numbers. Now from the string, we will read each character, and take its ASCII value, these ASCII values are converted into hexadecimal values. Then we can print them one by one.


using namespace std;
string dec_to_hex(int decimal){ //function is used to convert decimal to hex
   stringstream my_ss;
   my_ss << hex << decimal;
   return my_ss.str();
   string my_string = "This is a sample text";
   for(int i = 0; i<my_string.length(); i++){
      cout << dec_to_hex( << " ";


54 68 69 73 20 69 73 20 61 20 73 61 6d 70 6c 65 20 74 65 78 74
Updated on 30-Jul-2019 22:30:26