This repository was archived by the owner on May 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
123 lines (114 loc) · 3.44 KB
/
mainwindow.cpp
File metadata and controls
123 lines (114 loc) · 3.44 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
/**
* Constructor for main window
*/
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
this->ui->setupUi(this);
this->hash = new HashGenerator(new KeyPairQueue(),this->ui->threadSpinBox->value());
this->setupSignals();
}
/**
* De-Constructor for main window
*/
MainWindow::~MainWindow()
{
delete this->hash;
delete this->ui;
}
/**
* Link all the slots and signals between the UI and the HashGenerator
*/
void MainWindow::setupSignals()
{
//Start Button
this->connect(this->ui->startButton,
SIGNAL(clicked()),
this,
SLOT(onStartButtonClick()));
//Stop Button
this->connect(this->ui->stopButton,
SIGNAL(clicked()),
this,
SLOT(onStopButtonClick()));
//Target Found
this->connect(this->hash,
SIGNAL(targetFound(QString,QString,QString)),
this,
SLOT(targetFound(QString,QString,QString)));
//Update Progress
this->connect(this->hash,
SIGNAL(updatePercent(int)),
this->ui->progressBar,
SLOT(setValue(int)));
//Update Progress
this->connect(this->hash,
SIGNAL(done()),
this,
SLOT(hashesDone()));
//Change Thread Count
this->connect(this->ui->threadSpinBox,
SIGNAL(valueChanged(int)),
this->hash,
SLOT(setThreadNumber(int)));
}
/**
* Slot for UI start/pause button
*/
void MainWindow::onStartButtonClick()
{
if(this->ui->startButton->text() == tr("Start") || this->ui->startButton->text() == tr("Resume")) {
this->ui->startButton->setText(tr("Pause"));
this->ui->statusLabel->setText(tr("Running"));
this->hash->start();
}
else {
this->ui->startButton->setText(tr("Resume"));
this->ui->statusLabel->setText(tr("Idle"));
this->hash->stop();
}
}
/**
* Slot for UI stop button
*/
void MainWindow::onStopButtonClick()
{
this->hash->stop();
this->hash->changeQueue(new KeyPairQueue());
this->ui->startButton->setText(tr("Start"));
this->ui->statusLabel->setText(tr("Idle"));
this->ui->progressBar->setValue(0);
}
/**
* Slot called when HashGenerator reports a matching hash
*/
void MainWindow::targetFound(QString hash, QString salt, QString key)
{
qWarning() << "MATCH HAS BEEN FOUND! hash:" << hash << " salt:" << salt << " key:" << key;
//Target found! Pause search
this->ui->startButton->setText(tr("Resume"));
this->ui->statusLabel->setText(tr("Idle"));
this->hash->stop();
//update UI
QPalette plt;
plt.setColor(QPalette::WindowText, Qt::darkRed);
this->ui->targetFoundLabel->setPalette(plt);
this->ui->targetFoundLabel->setText(tr("You Are The Target!") + "\nKeypair:"+key+ "\nSalt:"+salt+"\nHash:" +hash);
}
/**
* Slot called when HashGenerator has run all the hashs
*/
void MainWindow::hashesDone()
{
//update UI
QPalette plt;
plt.setColor(QPalette::WindowText, Qt::darkGreen);
this->ui->targetFoundLabel->setPalette(plt);
this->ui->targetFoundLabel->setText(tr("System Passed. You are NOT the target."));
this->ui->startButton->setText(tr("Start"));
this->ui->statusLabel->setText(tr("Idle"));
this->hash->changeQueue(new KeyPairQueue());
}