-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataextraction.h
More file actions
172 lines (131 loc) · 4.24 KB
/
dataextraction.h
File metadata and controls
172 lines (131 loc) · 4.24 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <list>
#include "CFunctions.h"
#include "CVigenere.h"
class CDataExtraction
{
public:
void addData();
void extractData();
void help() {
std::cout << "No information.\n";
}
};
void CDataExtraction::addData()
{
CFunctions function;
CVigenere vigenere;
std::string sInput="";
std::string sWritter="";
std::cout << "Path: ";
function.m_getline(sInput);
ifstream read;
std::string sPath = "clear/";
sPath.append(sInput);
read.open(sPath);
std::cout << "Charactername: ";
function.m_getline(sInput);
sPath = "data/";
sPath.append(sInput);
ofstream write(sPath.c_str(),std::ios::out|std::ios::binary);
sInput = "";
std::string sBuffer;
while(!read.eof())
{
getline(read, sBuffer);
if(sBuffer.compare("#") == true)
continue;
const char* chBuffer = sBuffer.c_str();
char* chEncrypt = new char[20000];
vigenere.encryption(const_cast<char*>(chBuffer), const_cast<char*>("GAWASI"), chEncrypt);
write << chEncrypt << "\n";
}
std::cout << "writing finished...\n";
write.close();
}
void CDataExtraction::extractData()
{
CFunctions function;
CVigenere vigenere;
std::string sFromPerson;
std::cout << "Verdächtige Person (Name der verschlüsselten Datei): ";
function.m_getline(sFromPerson);
string sPath = "data/";
sPath.append(sFromPerson);
ifstream read(sPath.c_str(),std::ios::in|std::ios::binary);
if(!read)
{
std::cout << "Ausgewählte Person in unserem Datensatz nicht vorhanden.\n";
return;
}
std::list<std::string>* l_triggerWords = new std::list<std::string>;
std::string sBuffer;
for(int i=0;i<10;i++)
{
getline(read, sBuffer);
const char* chBuffer = sBuffer.c_str();
char* chDecrypt = new char[20000];
vigenere.decryption(const_cast<char*>(chBuffer), const_cast<char*>("GAWASI"), chDecrypt);
std::string sDecrypt = chDecrypt;
l_triggerWords->push_back(sDecrypt);
delete []chDecrypt;
}
std::list<std::string>* l_inputs = new std::list<std::string>;
while(!read.eof())
{
if(sBuffer.find("j") != std::string::npos)
{
std::string sNewInput;
while(!read.eof())
{
getline(read, sBuffer);
if(sBuffer[0] == 'j')
break;
const char* chBuffer = sBuffer.c_str();
char* chDecrypt = new char[20000];
vigenere.decryption(const_cast<char*>(chBuffer), const_cast<char*>("GAWASI"), chDecrypt);
sNewInput.append(chDecrypt);
sNewInput.append("\n");
}
l_inputs->push_back(sNewInput);
}
else
getline(read, sBuffer);
}
std::cout << "Informationen zu der verdächtigten person eingeben \n";
std::cout << "(Dies können einzelne Wörter oder kurze Phrasen sein. \n";
std::cout << "10 Eingaben möglich): \n";
std::list<std::string>* l_inputWords = new std::list<std::string>;
std::string sInput;
for(int i=0; i<10; i++)
{
std::cout << i << ": ";
function.m_getline(sInput);
l_inputWords->push_back(sInput);
}
unsigned int counter=0;
for(auto it=l_inputWords->begin(); it!=l_inputWords->end(); it++)
{
for(auto yt=l_triggerWords->begin(); yt!=l_triggerWords->end(); yt++)
{
if(function.compare((*it).c_str(), (*yt).c_str()) == true)
counter++;
}
}
std::cout << counter << " Übereinstimmungen.\n\n\n";
unsigned int sndCounter = 0;
for(auto it=l_inputs->begin(); it!=l_inputs->end(); it++)
{
if(sndCounter == 0 && counter >= 2)
std::cout << (*it) << "\n\n";
else if(sndCounter == 1 && counter >= 4)
std::cout << (*it) << "\n\n";
else if(sndCounter == 2 && counter >= 6)
std::cout << (*it) << "\n\n";
sndCounter++;
}
delete l_triggerWords;
}