mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
Хэширование пароля
This commit is contained in:
@@ -33,6 +33,8 @@ add_library(DataBaseLMS SHARED
|
||||
timingoftrainee.cpp
|
||||
timingoftrainee.h
|
||||
contactModel.h
|
||||
hashtools.cpp
|
||||
hashtools.h
|
||||
resources.qrc
|
||||
)
|
||||
|
||||
|
||||
14
DataBaseLMS/hashtools.cpp
Normal file
14
DataBaseLMS/hashtools.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "hashtools.h"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
HashTools::HashTools()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString HashTools::hashingMD5string(QString str)
|
||||
{// Вычисление MD5 хэша строки
|
||||
|
||||
QByteArray md5Hash = QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
return QString(md5Hash);
|
||||
}
|
||||
15
DataBaseLMS/hashtools.h
Normal file
15
DataBaseLMS/hashtools.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HASHTOOLS_H
|
||||
#define HASHTOOLS_H
|
||||
|
||||
#include <QString>
|
||||
#include "DataBaseLMS_global.h"
|
||||
|
||||
class DATABASELMS_EXPORT HashTools
|
||||
{
|
||||
public:
|
||||
HashTools();
|
||||
public:
|
||||
static QString hashingMD5string(QString str);
|
||||
};
|
||||
|
||||
#endif // HASHTOOLS_H
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "user.h"
|
||||
#include "hashtools.h"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
const QString User::TypeUserDBInstructor = "instructor";
|
||||
const QString User::TypeUserDBTrainee = "trainee";
|
||||
@@ -10,7 +12,14 @@ User::User():
|
||||
archived(),
|
||||
loggedIn(),
|
||||
TypeUserDB(),
|
||||
isAdmin(false)
|
||||
isAdmin(false),
|
||||
needSetPassword(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void User::hashingPassword()
|
||||
{
|
||||
// Вычисление MD5 хэша
|
||||
password = HashTools::hashingMD5string(password);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ public:
|
||||
|
||||
QString getTypeUserDB(){return TypeUserDB;}
|
||||
|
||||
bool getNeedSetPassword(){return this->needSetPassword;}
|
||||
void setNeedSetPassword(bool needSetPassword){this->needSetPassword = needSetPassword;}
|
||||
|
||||
void hashingPassword();
|
||||
|
||||
private:
|
||||
QString login;
|
||||
QString password;
|
||||
@@ -34,6 +39,7 @@ protected:
|
||||
QString TypeUserDB;
|
||||
|
||||
bool isAdmin;
|
||||
bool needSetPassword;
|
||||
};
|
||||
|
||||
#endif // USER_H
|
||||
|
||||
Reference in New Issue
Block a user