This repository was archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeveloperdialog.cpp
More file actions
65 lines (58 loc) · 1.36 KB
/
developerdialog.cpp
File metadata and controls
65 lines (58 loc) · 1.36 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
#include "developerdialog.h"
#include "ui_developerdialog.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
DeveloperDialog::DeveloperDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::DeveloperDialog)
{
ui->setupUi(this);
}
DeveloperDialog::~DeveloperDialog()
{
delete ui;
}
void DeveloperDialog::setlist(QJsonArray list)
{
this->list = list;
}
void DeveloperDialog::on_buttonBox_accepted()
{
QCryptographicHash hash(QCryptographicHash::Sha512);
hash.addData(ui->name->text().toLatin1().data());
QString namehash = hash.result().toHex().toLower();
hash.reset();
hash.addData(ui->password->text().toLatin1().data());
QString passwordhash = hash.result().toHex().toLower();
int index = -1;
for (int i = 0; i < list.size(); i++) {
QJsonObject jo = list.at(i).toObject();
if (jo.find("name")->toString() == namehash) {
index = i;
break;
}
}
if (index > -1) {
QJsonObject jo = list.at(index).toObject();
if (jo.find("password")->toString() == passwordhash) {
this->name = ui->name->text();
}
else {
QMessageBox::warning(this, "出错", "密码有误!");
this->name = "";
}
}
else {
QMessageBox::warning(this, "出错", "无效的用户名:" + ui->name->text());
this->name = "";
}
}
void DeveloperDialog::on_buttonBox_rejected()
{
this->name = "";
}
QString DeveloperDialog::result()
{
return this->name;
}