-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
executable file
·45 lines (35 loc) · 920 Bytes
/
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
#include "stdafx.h"
#include <iostream>
#include <sstream>
#include "Input.h"
#include "Enigma.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Input input;
int numRotors = input.numRotors();
Enigma *e = new Enigma(numRotors);
for (int i = 1; i <= numRotors; i++) {
RotorType type = input.addRotor(i);
e->addRotor(type);
}
char *dKey;
dKey = input.getChars(numRotors, "Set the daily key. Length: ");
e->setDailyKey(dKey);
char *mKey;
mKey = input.getChars(numRotors, "Set the message key. Length: ");
e->setMessageKey(mKey);
std::string en = e->encrypt("HALLO");
std::cout << en << std::endl;
std::string de = e->decrypt(en);
std::cout << de;
char quit;
cout << endl << "[q] Quit" << endl;
do {
quit = getchar();
} while (quit != 'q');
delete dKey; dKey = NULL;
delete mKey; mKey = NULL;
delete e; e = NULL;
return 0;
}