-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (54 loc) · 1.52 KB
/
main.cpp
File metadata and controls
67 lines (54 loc) · 1.52 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>
using namespace std;
int main()
{
int choice;
char secretKey;
string message;
bool isDone=false;
while(isDone==false){
cout << "\n 1-ciphering \n 2-deciphering \n 3-end program\n";
cin >> choice;
switch(choice){
case 1:{
cout << "please enter the message you want to cipher:\n";
cin.ignore();
getline(cin,message);
cout << "enter the secret key\n";
cin >> secretKey;
for(int i=0 ; i <= message.length() ; i++){
cout << ( char( message[i] ^ secretKey ) ) ;
}
cout << endl;
for(int c=0 ; c <= message.length() ; c++){
cout << hex << (int)( char( message[c] ^ secretKey ) ) ;
}
cout << endl;
break;
}
case 2:{
cout << "\nplease enter the message you want to decipher:\n";
cin.ignore();
getline(cin,message);
cout << "enter the secret key\n";
cin >> secretKey;
for(int i=0 ; i <= message.length() ; i++){
cout << ( char( message[i] ^ secretKey ) ) ;
}
cout << endl;
for(int c=0 ; c <= message.length() ; c++){
cout << hex << (int)( char( message[c] ^ secretKey ) ) ;
}
cout << endl;
break;
}
case 3:{
cout << "thanks for using our program , Good bye.\n";
isDone = true;
break;
}
}
}
return 0;
}