-
Notifications
You must be signed in to change notification settings - Fork 0
/
ask.h
54 lines (44 loc) · 1002 Bytes
/
ask.h
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
//
// Created by Adrian Mysak on 20.05.22.
//
#ifndef RSA_ASK_H
#define RSA_ASK_H
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
string askForMethod() {
string input;
while (true) {
cout << "Method: [enc/dec]: ";
cin >> input;
if (input == "enc" || input == "dec") {
return input;
}
}
}
ifstream askForIf(string filetype) {
string fname;
while (true) {
cout << filetype << " [relative]: ";
cin >> fname;
if (ifstream(fname)) {
return ifstream(fname);
} else {
cout << "\033[1;31mNo such file!\033[0m" << endl;
}
}
}
string askForMessage() {
string input;
while (true) {
cout << "Please enter your message: ";
cin >> input;
if (!input.empty()) {
return input;
} else {
cout << "\033[1;31mPlease enter a message!\033[0m" << endl;
}
}
}
#endif //RSA_ASK_H