Programming with Passion

Make the best out of everything.

Saturday 19 March 2016

C++ Programming Code to Decrypt Files

C++ Programming Code to Decrypt Files

Following C++ program ask to the user to enter file name (enter that file name which you have encrypted earlier) to decrypt that file:
/* C++ Program - Decrypt File */
  
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<stdlib.h>
void main()
{
 clrscr();
 char ch, choice, fname[20];
 fstream fps, fpt;
 cout<<"Enter file name (with extension like file.txt) which you have encrypted earlier to decrypt : ";
 gets(fname);
 fps.open(fname);
 if(!fps)
 {
  cout<<"Error in opening source file..!!";
  cout<<"\nPress any key to exit...";
  getch();
  exit(7);
 }
 fpt.open("temp.txt");
 if(!fpt)
 {
  cout<<"Error in opening temp.txt file..!!";
  fps.close();
  cout<<"\nPress any key to exit...";
  getch();
  exit(9);
 }
 while(fpt.eof()==0)
 {
  fpt>>ch;
  ch=ch-100;
  fps<<ch;
 }
 cout<<"File "<<fname<<" decrypted successfully..!!";
 cout<<"\nPress any key to exit...";
 fps.close();
 fpt.close();
 getch();
}
When the above C++ program is compile and executed, it will produce the following result:
C++ program to decrypt file content
Now you can watch your file's content, you will see that your file's content will be decrypted i.e., you will watch your original content.


https://www.youtube.com/watch?v=yHJmz9NNklk

No comments:

Post a Comment