-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
138 lines (126 loc) · 2.78 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "base64.h"
#include "xor.h"
#include "scoring.h"
int main() {
char command;
string main_menu = "\nMAIN MENU\n1: Base64 options\n2: Xor options\nh: Print this menu\nq: Quit\n\n";
string base64_options = "\nBASE64 OPTIONS\n1: Convert Hex to Base 64 \n2: Convert Base 64 to Hex\nh: Print this menu\nb: Back to main menu\n\n";
string Xor_options = "\nXOR OPTIONS\n1: Fixed Xor of two hex strings (equal length)\n2: Break single byte Xor\n3: Detect and break single byte Xor\n4: Perform repeating key Xor\n5: Break Repeating Key Xor\nh: Print this menu\nb: Back to main menu\n\n";
cout << main_menu;
cout << "Kryptos>";
while(1) {
command = cin.get();
if(command == '\n') {
cout << "Kryptos>";
}
switch (command) {
{case '1' :
cout << base64_options;
bool loop = true;
while(loop) {
command = cin.get();
if(command == '\n') {
cout << "Kryptos/b64>";
}
switch(command) {
{case '1':
string input;
cout << "Hex string: ";
cin >> input;
cout << "\noutput: " << hextob64(input) << "\n";
break;
}
{case '2':
string input;
cout << "Base 64 string: ";
cin >> input;
cout << "\noutput: " << b64tohex(input) << "\n";
}
{case 'h':
cout <<base64_options;
break;
}
{case 'b':
cout << main_menu;
loop=false;
break;
}
{case 'q':
cout << main_menu;
loop=false;
break;
}
}
}
break;
}
{case '2':
cout << Xor_options;
bool loop = true;
while(loop) {
command = cin.get();
if(command == '\n') {
cout << "Kryptos/Xor>";
}
switch(command) {
{case '1':
string inputone;
string inputtwo;
cout << "First hex string: ";
cin >> inputone;
cout << "Second hex string: ";
cin >> inputtwo;
cout << "\noutput: " << fixedXor(inputone,inputtwo) << "\n";
break;
}
{case '2':
string input;
cout << "Hex to break: ";
cin >> input;
sByteXor(input);
scoring();
break;
}
{case '3':
detectXor();
scoring();
}
{case '4':
string input;
cout << "Enter a key: ";
cin >> input;
repeating_Xor(input);
cout << "Output written to repeating_xor_output.txt\n";
}
{case '5':
break_Rkey_Xor();
}
{case 'h':
cout << Xor_options;
break;
}
{case 'b':
cout << main_menu;
loop=false;
break;
}
{case 'q':
cout << main_menu;
loop=false;
break;
}
}
}
break;
}
{case 'h':
cout << main_menu;
break;
}
{case 'q':
return 0;
}
}
}
return 0;
}