-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn.cpp
More file actions
97 lines (77 loc) · 2.34 KB
/
return.cpp
File metadata and controls
97 lines (77 loc) · 2.34 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
/*
soremant is designed to replace oper managemnt of stores in the NZCF
Copyright (C) 20201 Charles Kern-Smith
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <QDateTime>
#include "return.h"
#include "ui_return.h"
Return::Return(QWidget *parent ,int initid ,QString initname ,QString initdate ,QByteArray initpwdhash) :
QDialog(parent),
ui(new Ui::Return)
{
//initalizes important data
id = initid;
name = initname;
date = initdate;
pwdsha = initpwdhash;
ui->setupUi(this);
}
Return::~Return()
{
delete ui;
}
void Return::on_buttonBox_accepted()
/* complimentary record map
*
*/
{
//checks what radiobutton is checked
QString condition;
QString key;
if (ui->button_single->isChecked()){
key = QString::number(id);
condition = "id";
}
else if (ui->button_multiple->isChecked()){
key = date;
condition = "date";
}
else{
key = name;
condition = "name";
}
QByteArray shahash;
QString newpass = ui->lineEdit->text();
if (( shahash = hashsha(newpass)) == pwdsha){
QStringList * record = new QStringList;
//sets arguments for updating record
*record << key;
*record << shahash;//.toHex();
*record << hashmd5(newpass).toHex();
*record << QDateTime::currentDateTime().toString();
*record << condition;
mwhandle->handinRecord(record);
}
}
QByteArray Return::hashsha(QString pwd)
{
QCryptographicHash hash(QCryptographicHash::Sha3_512);
hash.addData(pwd.toUtf8());
return hash.result().toHex();
}
QByteArray Return::hashmd5(QString pwd)
{
QCryptographicHash hash(QCryptographicHash::Md5);
hash.addData(pwd.toUtf8());
return hash.result();
}