-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (45 loc) · 1.39 KB
/
main.cpp
File metadata and controls
48 lines (45 loc) · 1.39 KB
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
39
40
41
42
43
44
45
46
47
48
// FCI – Programming 1 – 2018 - Assignment 2
// Program Name:Rot13 cipher
// Last Modification Date: 27/2/2018
// Author1 and ID and Group: Mai Mostafa Abd El-Rahman & 20170303 & G12
// Teaching Assistant:Eng.Khdega
// Purpose:Encrypting messages
#include <iostream>
using namespace std;
int main()
{
while(true){
string sentence;
int answer;
char cipher;
cout<<"\nAhlan ya user ya habibi"<<endl;
cout<<"\nwhat do you like to do today?\n\n1-cipher a message\n2-decipher a message\n3-end"<<endl;
cin>>answer;
if ((answer==1) || (answer==2)){
if(answer == 1)
cout<<"\nenter sentence to cipher: "<<endl;
else
cout<<"\nenter sentence to decipher: "<<endl;
cin.get();
getline(cin,sentence);
for (int i=0; i<sentence.length() ;i++){
if( sentence[i] == ' '){
cout<<sentence[i];
continue;
}
if((sentence[i] > 64) && (sentence[i] < 91) || ((sentence[i] > 96) && (sentence[i] < 123)))
cipher = (int)sentence[i] + 13;
else
cipher = (int)sentence[i];
if ((cipher < 0) || (cipher > 122))
cipher = cipher - 122 + 96;
cout <<cipher;
}
cout<<endl;
}
if (answer==3){
cout<<"goodbye";
break;
}
}
}