Advertisement
xakzi

Decryption console app c++

Sep 26th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. char name[100],target[100],ch,mod; //Declare Variables
  2. char key = 97;
  3.  
  4. cout<<"Enter The Path Of A File Name Which Is To Be Decrypted : ";
  5. cin >> name;
  6.  
  7. ifstream fin(name,ios::binary);
  8. if(!fin) //Open The Encryped File In A Binary Mode
  9. {
  10.     cout<<"Error In Opening Of A File : ";
  11.     _getch();
  12.     return 1; //Show Error If File Does Not Exist
  13. } //Or Any Occurs In Opening Of A File
  14.  
  15. cout<<"Enter The New Decrypted File Name : ";
  16. cin >> target;
  17. ofstream fout;
  18. fout.open(target,ios::binary); //Opens The Output File In An Binary Mode
  19. if(!fout)
  20. { //Show Error If Any Error Occurs In Opening Of A File
  21.     cout<<"Error In Opening Of A Target File : ";
  22.     _getch();
  23.     return 1;
  24. }
  25.  
  26. while(fin.get(ch))
  27. { //Opens The Encryped File
  28.     if(ch==EOF)break;  
  29.     mod = ch + key;
  30.     if ( mod > 255) mod -= 255;
  31.     fout << mod;
  32. }
  33.  
  34. fin.close(); //Close The EncryptedFile
  35. fout.close(); //Close Your OriginalDecrypted File
  36.  
  37. cout<<"The File Is Being Decrypted............ ";
  38. _getch();
  39.  
  40. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement