ErrorC1083Cannot open include file: 'CryptHash/CryptHash.h': No such file or directory

54 Views Asked by At

I have downloaded https://github.com/alecgn/crypthash-net and moved it to the project's folder.This project is saved in main.cpp.

#include <CryptHash/CryptHash.h>
#include <bcrypt.h>
using namespace bcrypt;




class SecureEncryptor {
public:
static std::string hash_password(const std::string& password) {
Generate a random salt
std::string salt = generate_salt();
// Concatenate salt and password, then hash using bcrypt
std::string salted_password = salt + password;
std::string hashed_password = bcrypt::generateHash(salted_password);

// Store salt and hashed password securely in your database

return salt + hashed_password;
}

static bool verify_password(const std::string& password, const std::string& stored_password) {

// Extract salt from stored_password

std::string salt = stored_password.substr(0, BCRYPT_HASHSIZE);

// Concatenate salt and entered password, then hash using bcrypt

std::string salted_password = salt + password;
std::string hashed_password = bcrypt::generateHash(salted_password);

// Compare the hashed passwords

return stored_password == (salt + hashed_password);
}

private:
static std::string generate_salt() {

// Generate a secure random salt using bcrypt

return bcrypt::generateSalt();
}
};

Please tell me step by step to download the bcypt file and connect it to the project and mysql, Xampp

2

There are 2 best solutions below

1
boardkeystown On

friend,

this is a C# library. So the awnser is you can't. Unless you find a C# to cpp bride / interface of some kind. Otherwise you may want to consider a different cpp library for your task.

0
Alessandro Cagliostro On

Friend, I'm the owner of CryptHash.NET lib; this is a .NET library, so, you can't use it with C++. Thanks by being interested in it, but I recommend you to consider/find a cpp library, as the others have said, unless you find a C# to cpp bride / interface of some kind, you will not be able to use it, but I personally don't recommend that, it's not worth the work you'll have.