forked from shm0nya/Lipilin-s-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asimetry.cpp
78 lines (63 loc) · 1.68 KB
/
asimetry.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
#include "asimetry.h"
#include "ui_asimetry.h"
using namespace std;
asimetry::asimetry(QWidget *parent) :
QDialog(parent),
ui(new Ui::asimetry)
{
ui->setupUi(this);
this->setWindowTitle("Ключи RSA");
ui->progress_bar_exchange->setVisible(false);
}
asimetry::~asimetry()
{
delete ui;
}
void asimetry::on_button_generate_clicked()
{
srand(time(0));
int p = prostoe_chislo(100);
int q = prostoe_chislo(100);
n = p*q;
long long int phi = (p - 1)*(q - 1);
e = (int)take_e(phi);
d = (int)take_d(e, phi);
QString s = QString::number(p);
ui->lbl_p_value->setText(s);
s = QString::number(q);
ui->lbl_q_value->setText(s);
s = QString::number(n);
ui->lbl_n_value->setText(s);
s = QString::number(phi);
ui->lbl_f_n_value->setText(s);
s = QString::number(e);
ui->lbl_e_value->setText(s);
s = QString::number(d);
ui->lbl_d_value->setText(s);
flag_key_generated = true;
}
void asimetry::on_button_exchange_clicked()
{
if (!flag_key_generated)
{
QMessageBox::information(this, "error", "Ключи не сгенерированы!");
return;
}
ui->progress_bar_exchange->setVisible(true);
for (int i = 0; i < 100; i++)
{
QEventLoop loop;
QTimer::singleShot(mc, &loop, SLOT(quit()));
loop.exec();
loop.exit();
ui->progress_bar_exchange->setValue(i+1);
}
ui->label_4->setText("2713");
ui->progress_bar_exchange->setVisible(false);
ui->lbl_status_value->setText("Обмен завершен");
emit this->keys_was_generated(n, e, d);
}
void asimetry::on_button_back_clicked()
{
emit this->from_rsa_to_home_wnd();
}