错误C1083无法打开包含文件:'CryptHash/CryptHash.h':没有这样的文件或目录

问题描述 投票:0回答:1

我已经下载了https://github.com/alecgn/crypthash-net并将其移动到项目的文件夹中。该项目保存在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();
}
};

请一步步告诉我下载bcypt文件并连接到项目和mysql、Xampp

c++ mysql password-hash
1个回答
0
投票

朋友,

这是一个 C# 库。 所以,你不能。除非你找到一个 C# 到 cpp 的新娘/某种类型的接口。否则,您可能需要考虑使用不同的 cpp 库来完成您的任务。

© www.soinside.com 2019 - 2024. All rights reserved.