rendered paste body/*
File: Encrypt-Decrypt.cpp
Author: Brolly
Description: encryption/decryption
Date: 31/04/07
*/
#include <iostream>
#include <string>
using namespace std;
void encrdecr();
void cls();
void pause();
string txt;
string key;
void main()
{
int choice=0;
do {
cls();
cout << "\n\t\t\t1. Encrypt" << endl;
cout << "\t\t\t2. Decrypt" << endl;
cout << "\t\t\t3. Exit" << endl;
cin >> choice;
}while((choice!=1) && (choice!=2) && (choice!=3));
if(choice==1) {
cls();
encrdecr();
}
else if(choice==2) {
cls();
encrdecr();
}
else if(choice==3)
exit(0);
}
void encrdecr() {
cout << "Enter text: " << endl;
cin >> txt;
cout << endl << "Key: ";
cin >> key;
for(int i=0;i<txt.length();i++)
txt[i]=txt[i]^key[i%key.length()];
cout << endl << "Text: " << endl << txt << endl << endl;
pause();
cls();
main();
}
void cls() {
system("cls");
}
void pause() {
system("pause");
}