forked from ALPHAVIO/Hacktoberfest-PR-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
38 lines (33 loc) · 723 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
using namespace std;
int main()
{
char txt[100],option;
int key;
cout<<"Enter plaintext : ";
cin.getline(txt,100);
cout<<"Enter key : ";
cin>>key;
reoptn:
cout<<"Enter option ( e for encryption, d for decryption ) : ";
cin>>option;
if(option == 'e' || option == 'E')
{
for(int i = 0 ; txt[i] != '\0' ; i++)
{
txt[i] += key;
}
cout<<"Encrypted text : "<<txt;
}
else if ( option == 'd' || option == 'D')
{
for(int i = 0; txt[i] != '\0'; i++)
{
txt[i] -= key;
}
cout<<"Decrypted text : "<<txt;
}
else
{cerr<<"Invalid option, exiting program ";}
return 0;
}