-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.cpp
42 lines (37 loc) · 1.26 KB
/
settings.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
#include "settings.h"
#include "qdebug.h"
#include <QCoreApplication>
#include <QCryptographicHash>
Settings::Settings()
{
QCoreApplication::setOrganizationName("AdnCorp");
QCoreApplication::setApplicationName("pwd");
QString qsHashPwd;
QByteArray pwdHashed;
QSettings settings("pwdrc", QSettings::IniFormat);
settings.beginGroup("Security");
if(!settings.contains("pwd")){
// qDebug()<<"=Set Default pwd=";
pwdHashed = QCryptographicHash::hash(defaultPwd.toLocal8Bit(), QCryptographicHash::Sha256);
qsHashPwd = QString(pwdHashed);
writeSettings("Security","pwd", qsHashPwd);
}
settings.endGroup();
}
void Settings::writeSettings(const QString group ,const QString key, const QString value){
QSettings settings("pwdrc", QSettings::IniFormat);
settings.beginGroup(group);
settings.setValue(key, value);
QString aa = settings.value(key).toString();
settings.endGroup();
}
QString Settings::readSettings(const QString group,const QString key){
QSettings settings("pwdrc", QSettings::IniFormat);
QString value;
QString defaultValue ="a";
QVariant qv(defaultValue);
settings.beginGroup(group);
value = settings.value(key,qv).toString();
settings.endGroup();
return value;
}