-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (47 loc) · 1.3 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
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include "library.h"
int main() {
int key = 0;
while (true) {
int n;
try {
std::string s;
std::cout << "Chose the command: ";
getline(std::cin, s);
n = std::stoi(s);
if (n < 0) throw 1;
}
catch (...) {
std::cerr << "You must answer with a whole number >= 0." << std::endl;
continue;
}
fflush(stdin);
if (n > 2) {
std::cout << "The command is not implemented!" << std::endl;
continue;
}
system("clear");
if (n == 1) {
std::string text;
std::cout << "Enter the text: ";
std::cin >> text;
fflush(stdin);
std::string key;
std::cout << "Enter key: ";
std::cin >> key;
fflush(stdin);
std::cout << Encrypt(text,std::stoi(key)) << std::endl;
}
if (n == 2) {
std::string text;
std::cout << "Enter the text: ";
std::cin >> text;
fflush(stdin);
std::string key;
std::cout << "Enter key: ";
std::cin >> key;
fflush(stdin);
std::cout << Decrypt(text,std::stoi(key)) << std::endl;
}
}
}