-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
36 lines (33 loc) · 1.15 KB
/
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
#include "caesar-cipher.h"
int main() {
cout << "\nWelcome to Julius Caesar's Shift Cipher!"
"\nEnter an integer to shift the normal alphabet left by that number of positions." << endl;
cout << "Then, enter a message that will be encrypted using the generated cipher alphabet." << endl;
cout << "https://en.wikipedia.org/wiki/Caesar_cipher\n" << endl;
int option;
string plainAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for(;;) {
cout << "(1) Encrypt, (2) Decrypt, (0) Quit: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Error! Invalid input." << endl;
continue;
}
switch (option) {
case 0:
return 0;
case 1:
encryption(plainAlpha);
break;
case 2:
decryption(plainAlpha);
break;
default:
cout << "Error! Invalid choice." << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
}