hash users paswords

This commit is contained in:
2020-05-26 21:58:33 +02:00
parent df772fec57
commit a21f94bb69
2 changed files with 18 additions and 3 deletions

View File

@@ -5,6 +5,8 @@
#include <sys/wait.h>
#include <iostream>
#include <cstring>
#include <openssl/sha.h>
#include <openssl/evp.h>
session_manager::session_manager(int fd)
{
@@ -17,7 +19,12 @@ bool session_manager::validate_pass(){
this->read_data(buffer, 256);
std::string user=buffer;
this->read_data(buffer, 256);
std::string pass=buffer;
// std::string pass=buffer;
unsigned char hash[SHA512_DIGEST_LENGTH];
SHA512(reinterpret_cast<unsigned const char*>(buffer), strlen(buffer), hash);
unsigned char encodedData[200];
EVP_EncodeBlock(encodedData, hash, sizeof (hash));
std::string pass=std::string(reinterpret_cast<char*>(encodedData));
if(this->data->get_passwd(user)==pass){
this->write_data("pass");
if(this->data->get_admin(user)){