Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Desteg.hpp"
- int main ( int argc, char** argv )
- {
- // initialize SDL video
- if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
- {
- return 1;
- exit(0);
- }
- // make sure SDL cleans up before exit
- atexit(SDL_Quit);
- // load an image
- SDL_Surface *image = SDL_LoadBMP("image2.bmp");
- if (!image)
- {
- return 2;
- exit(0);
- }
- algorithm desteg;
- //input key
- string key;
- cin>>key;
- //create output file
- fstream file;
- file.open("file.txt",ios::out);
- //check if file loads
- if(!file)
- {
- return 3;
- exit(0);
- }
- //create bool array that stores text length in binary form
- bool lengthBin[64];
- //read text length from first 64 least significant bits and save in an array
- desteg.readLength(image,lengthBin);
- //convert length from binary to decimal form and keep it as a new variable
- unsigned int textSize = desteg.length(image,lengthBin);
- //create bool array that stores text in binary form
- bool *textBin=new bool[3*image->w*image->h-64];
- //read text from the least significant bits and save it in an array
- desteg.desteganography(image,textBin,textSize);
- //convert text from binary to decimal form and save it in a string array
- string text=desteg.binToDec(textBin,image,textSize);
- //decode text (xor) with key
- string decoded=desteg.coding(textSize,text,key,image);
- cout<<decoded;
- //save decoded text in output file
- file<<decoded;
- //deallocate
- delete[] textBin;
- SDL_FreeSurface(image);
- SDL_Quit();
- //close the file
- file.close();
- system("pause >nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement