Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include "Desteg.hpp"
  2.  
  3. int main ( int argc, char** argv )
  4. {
  5. // initialize SDL video
  6. if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  7. {
  8. return 1;
  9. exit(0);
  10. }
  11.  
  12. // make sure SDL cleans up before exit
  13. atexit(SDL_Quit);
  14.  
  15. // load an image
  16. SDL_Surface *image = SDL_LoadBMP("image2.bmp");
  17. if (!image)
  18. {
  19. return 2;
  20. exit(0);
  21. }
  22.  
  23. algorithm desteg;
  24.  
  25. //input key
  26. string key;
  27. cin>>key;
  28.  
  29. //create output file
  30. fstream file;
  31. file.open("file.txt",ios::out);
  32.  
  33. //check if file loads
  34. if(!file)
  35. {
  36. return 3;
  37. exit(0);
  38. }
  39.  
  40. //create bool array that stores text length in binary form
  41. bool lengthBin[64];
  42.  
  43. //read text length from first 64 least significant bits and save in an array
  44. desteg.readLength(image,lengthBin);
  45.  
  46. //convert length from binary to decimal form and keep it as a new variable
  47. unsigned int textSize = desteg.length(image,lengthBin);
  48.  
  49. //create bool array that stores text in binary form
  50. bool *textBin=new bool[3*image->w*image->h-64];
  51.  
  52. //read text from the least significant bits and save it in an array
  53. desteg.desteganography(image,textBin,textSize);
  54.  
  55. //convert text from binary to decimal form and save it in a string array
  56. string text=desteg.binToDec(textBin,image,textSize);
  57.  
  58. //decode text (xor) with key
  59. string decoded=desteg.coding(textSize,text,key,image);
  60. cout<<decoded;
  61.  
  62. //save decoded text in output file
  63. file<<decoded;
  64.  
  65. //deallocate
  66. delete[] textBin;
  67.  
  68. SDL_FreeSurface(image);
  69. SDL_Quit();
  70.  
  71. //close the file
  72. file.close();
  73.  
  74. system("pause >nul");
  75.  
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement