-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread(1).cpp
More file actions
83 lines (59 loc) · 1.89 KB
/
Copy paththread(1).cpp
File metadata and controls
83 lines (59 loc) · 1.89 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
#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)
{
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;
QFileInfo fileInfo(fileNameIn);
this->_size = fileInfo.size();
QFileInfo fileinfo2(fileNameOut);
}
void Thread::run()
{
Crypto *crypto = new Crypto();
qDebug()<< _mode;
crypto->setMode(_mode.toStdString());
std::string vi = ui->lineEdit->text().toStdString();
if (this->_ED == true)
crypto->encrypt(this->_inputFile, this->_outputFile, vi,this->_size);
else
crypto->decrypt(this->_inputFile, this->_outputFile,vi, this->_size);
/*while (true){
QFileInfo fileInfo1(fileNameIn);
double sizeIn = fileInfo1.size();
QFileInfo fileinfo2(fileNameOut);
double sizeOut;
sizeOut = fileinfo2.size();
int temp = (int)((sizeOut/sizeIn)*100);
if (temp > 99) break;
else ui->progressBar->setValue(temp);
}*/
this->_inputFile.close();
this->_outputFile.close();
this->_keyFile.close();
delete crypto;
}