-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (36 loc) · 1.01 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
#include"enigma.h"
#include"error_handler.h"
#include"errors.h"
#include<vector>
#include<cstring>
using namespace std;
int main(int argc, char** argv){
vector<char> message;
char ch;
int error_code;
Error_handler error_handler;
/*Testing Errors*/
error_code = error_handler.error_testing(argc, argv);
if(error_code != NO_ERROR){
return error_code;
}
/*Getting user input and checking its validity. */
while(cin >> ws >> ch){
error_code = error_handler.check_character(ch);
if(error_code != 0){
break;
}else{
message.push_back(ch);
}
}
/*Creating Enigma and initialising its components with input files. */
auto machine = Enigma(argc, argv);
/*Encrypting a message by passing it by reference. */
machine.encrypt_message(message);
/*Printing message*/
for(auto char_index = 0u; char_index < message.size(); char_index++){
cout << message[char_index];
}
return error_code;
}