I think all of us have dreamed of a secret language with our friends https://www.codeproject.com/script/images/smiley_smile.gif , well this program simply hides any text file (can contain a secret message to any friend https://www.codeproject.com/script/images/smiley_smile.gif ) in a bmp file . No one can feel or see any changes to the picture , and you then simply send this picture to your friend who will use a certain password to recover the text file .
I hope you enjoy my program and please don't forget to vote for my program https://www.codeproject.com/script/images/smiley_smile.gif . At last I want to say that it is my first time to put my programs in the internet and to put comments in the sources.
Structure of text file:
Any text file consists of streams of characters , each character is 1 byte (ASCII code) each byte as all of us of course know consists of 8 bits .
The function which is used to convert the ASCII code (decimal) to the binary equivalent called
CreateBinLookUpTable() , which simply creates an array as following :
There are many methods to convert from decimal to binary but I found this is from the fastest methods.
Bitmap file structure:
In general the bmp file consists in of two parts a header and the data part.
In the c/c++ there is a bitwise operator ,one of these operators is the AND " & " , to see the AND operation look at the following table :
How To change a certain bit in a byte using MASK:
if we have 'H' '0100 1001' and we want to change the last bit to 0 simply we ANDed 'H' with the mask 254 ('1111 1110) , the result will be '0100 1000' and if the last bit is '0' and we want to change it to 1 so we first ANDed with the same mask then add 1.
Using the code
Hiding the text in the bmp file technique:
- Reading the text file and converting each char. to 8 bits in array
- Reading the bmp file and ANDing each byte with the mask 254 '1111 1110'.
- Then adding to it 1 or not depending on the
- Saving the result back to the bmp file.
- Well since it is just one bit change in each byte so our eye never be able to see the such difference.
Points of Interest
When you are going to try my demo ,you will find three pictures ,use them with the program using the password 'aaaaa' (take care it is CASE SENSTIVE) and read my msg to you https://www.codeproject.com/script/images/smiley_smile.gif then vote for my work .
These samples pictures are in the demo and with the source in the release folder.
Now see the following the picture; can you see any difference between two pictures https://www.codeproject.com/script/images/smiley_smile.gif
Hey now one might ask if there is a way to know if this pic hold a msg inside it or not ?? https://www.codeproject.com/script/images/smiley_smile.gif Well I found indeed one method ,I discovered it by chance but it can be used only for a black or a white image. This using the famous program 'Paint Shop Pro' ,there is something called 'Split to HSL' ,you will find a new image created called saturation .
Following image show us how my msg is hidden in the image https://www.codeproject.com/script/images/smiley_smile.gif
Thanks a lot For Your Time. Don't forget to vote for my program https://www.codeproject.com/script/images/smiley_smile.gif