
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Best Way to Hide a String in Binary Code in C++
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.
Example
#include<iostream> #include<sstream> 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(); } main(){ string my_string = "This is a sample text"; for(int i = 0; i<my_string.length(); i++){ cout << dec_to_hex(my_string.at(i)) << " "; } }
Output
54 68 69 73 20 69 73 20 61 20 73 61 6d 70 6c 65 20 74 65 78 74
Advertisements