hash users paswords
This commit is contained in:
@@ -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)){
|
||||
|
||||
Reference in New Issue
Block a user