hash users paswords
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#include "msql_acces.h"
|
||||
#include <iostream>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <string.h>
|
||||
|
||||
msql_acces::msql_acces()
|
||||
{
|
||||
driver = get_driver_instance();
|
||||
@@ -103,10 +107,14 @@ bool msql_acces::get_package_exists(std::string package){
|
||||
|
||||
void msql_acces::create_user(std::string user, std::string pass, bool admin){
|
||||
sql::PreparedStatement *pstmt = con->prepareStatement("insert into users(username, passwd, admin) values(?, ?, ?)");
|
||||
unsigned char hash[SHA512_DIGEST_LENGTH];
|
||||
SHA512(reinterpret_cast<unsigned const char*>(pass.data()), strlen(pass.data()), hash);
|
||||
unsigned char encodedData[200];
|
||||
EVP_EncodeBlock(encodedData, hash, sizeof (hash));
|
||||
pstmt->setString(1,user);
|
||||
pstmt->setString(2,pass);
|
||||
pstmt->setString(2,std::string(reinterpret_cast<char*>(encodedData)));
|
||||
pstmt->setBoolean(3,admin);
|
||||
sql::ResultSet *res = pstmt->executeQuery();
|
||||
pstmt->executeQuery();
|
||||
}
|
||||
|
||||
void msql_acces::remove_user(std::string user){
|
||||
|
||||
Reference in New Issue
Block a user