-
Notifications
You must be signed in to change notification settings - Fork 84
/
ProductKey.cpp
executable file
·74 lines (68 loc) · 2.11 KB
/
ProductKey.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
#include "ProductKey.h"
#include "ui_ProductKey.h"
#include "DebugEngine.h"
#include "OptionEngine.h"
#include "SystrayIcon.h"
#include "FacilityEngine.h"
#include <QMessageBox>
#include <QCryptographicHash>
ProductKey::ProductKey(QWidget *parent) :
QDialog(parent),
ui(new Ui::ProductKey)
{
ui->setupUi(this);
parseKey();
}
ProductKey::~ProductKey()
{
delete ui;
}
bool ProductKey::parseKey(QString orgkey)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"ultimate key");
QString key=orgkey;
if(orgkey.isEmpty())
key=QString::fromStdString(OptionEngine::optionEngine->getOptionValue("Ultracopier","key"));
if(!key.isEmpty())
{
QCryptographicHash hash(QCryptographicHash::Sha256);
hash.addData(QStringLiteral("TxUd5cp4dwAqHAHZUhH84FuT").toUtf8());//a salt
hash.addData(key.toUtf8());
const QByteArray &result=hash.result();
if(!result.isEmpty() &&
result.at(0)==0x00 && result.at(1)==0x00 && result.at(2)==0x21 && (result.at(3)&0x0f)==0x00
)
{
if(!orgkey.isEmpty())
OptionEngine::optionEngine->setOptionValue("Ultracopier","key",key.toStdString());
ultimate=true;
}
else
ultimate=false;
}
else
ultimate=false;
return ultimate;
}
bool ProductKey::isUltimate() const
{
#ifdef ULTRACOPIER_VERSION_ULTIMATE
return true;
#else
return ultimate;
#endif
}
void ProductKey::on_buttonBox_accepted()
{
if(!ProductKey::parseKey(ui->productkey->text()))
QMessageBox::critical(this,tr("Error"),"<br />"+tr("Your product key was rejected for this version %1.<br /><b>If you have just buy the key, try download the last version.</b><br />If you buy key, unmark check your spam and unmark the mail as spam<br />If you have not buy your key, go to <a href=\"https://ultracopier.herman-brule.com/#ultimate\">https://ultracopier.herman-brule.com/#ultimate</a>").arg(QString::fromStdString(FacilityEngine::version())));
else
{
changeToUltimate();
hide();
}
}
void ProductKey::on_buttonBox_rejected()
{
hide();
}