Хэширование пароля

This commit is contained in:
2025-10-16 17:11:58 +03:00
parent 8e931f229b
commit 241382d305
19 changed files with 221 additions and 116 deletions

View File

@@ -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
View 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
View 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

View File

@@ -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);
}

View File

@@ -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