-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.cpp
More file actions
73 lines (49 loc) · 1.56 KB
/
Copy paththread.cpp
File metadata and controls
73 lines (49 loc) · 1.56 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
#include "thread.h"
#include "crypto.h"
#include "ui_mainwindow.h"
#include "mainwindow.h"
#include <QMainWindow>
#include <fstream>
#include <QFileInfo>
#include <string>
#include <cstring>
#include <iostream>
#include <QtDebug>
Thread::Thread(QString fileNameIn, QString fileNameOut, QString fileNameKey,bool ED, QString mode, std::string vi)
{
this->_inputFile = std::ifstream(fileNameIn.toStdString());
if ( !_inputFile.is_open() ) {
qDebug() << "Ошибка открытия файла.\n";
return;
}
this->_outputFile = std::ofstream(fileNameOut.toStdString());
if ( !_outputFile.is_open() ) {
qDebug()<< "Ошибка открытия файла.\n";
return;
}
this->_keyFile = std::ifstream(fileNameKey.toStdString());
if ( !_keyFile.is_open() ) {
qDebug() << "Ошибка открытия файла.\n";
return;
}
this->_ED = ED;
this->_mode = mode;
this->_vi = vi;
QFileInfo fileInfo(fileNameIn);
this->_size = fileInfo.size();
QFileInfo fileinfo2(fileNameOut);
}
void Thread::run()
{
Crypto *crypto = new Crypto();
qDebug()<< _mode;
crypto->setMode(_mode.toStdString());
if (this->_ED == true)
crypto->encrypt(this->_inputFile, this->_outputFile, this->_vi,this->_size);
else
crypto->decrypt(this->_inputFile, this->_outputFile,this->_vi, this->_size);
this->_inputFile.close();
this->_outputFile.close();
this->_keyFile.close();
delete crypto;
}