Beruflich Dokumente
Kultur Dokumente
Atul Sharma
Bonafide Certificate
1
Index
2
Acknowledgement
3
Abstract
4
Introduction
5
Program Code
#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<fstream.h>
#include<process.h>
#include<ctype.h>
class Encrypt
{ private:
char line[80];
int key;
public:
void getdata();
void enc();
void dec();
void mix();
};
void Encrypt::getdata()
{ cout <<"\n\n\tEnter your text document to encrypt: "<<"\n\t";
cin.getline(line,500);
}
void Encrypt::enc()
{ int length;
char *enc;
key = 4;
enc = line;
length = strlen(line);
6
for (int i = 0; i < length; i++) {
*enc += key;
enc++;
}
cout << "\n\tEncrypted text is: \n\t" <<line<<endl;
}
void Encrypt::dec()
{ int length,pin;
char *dec;
char ch;
key = 4;
dec = line;
length = strlen(line);
for (int i = 0; i < length; i++) {
*dec -= key;
dec++;
}
cout<<"\n\tDo you wish to decrypt the file(Y/N)"<<endl;
cin>>ch;
if(toupper(ch=='Y'))
{cout<<"\n\tPlease enter the end server key to decrypt the text:"<<endl;
cin>>pin;
if(pin==1220)
{ cout << "\t\nDecrypted text is: \n\t" << line << endl;
getch();
}
else
7
{cout<<"\n\tWrong key,plz try again!!"<<endl;
exit(0);
}}
else
cout<<"\n\tThank you. You are exiting";
}
void Encrypt::mix()
{ char rply;
cout<<"\t\t\nDo you want to save the file(Y/N)\n\t";
cin>>rply;
if(toupper(rply=='Y'))
{ofstream save("file.txt;ios::out;");
save<<line;
save.close();}
else
exit(0);}
void main ()
{
Encrypt text;
cout<<"\t\t\t\t\tWelcome\n\tThis is a Ceaser Cipher Program Helping you keep your File
Safe'\ n"<<endl;
text.getdata();
text.enc();
text.mix();
text.dec();
}
8
Sample output
9
10
11
Bibliography
2. www.tutorialspoint.com/cplusplus/
3. www.geekforgeeks.org/c-plus-plus/
4. www.reddit.com/r/cpp
12