我正在尝试使用 C++ 密码库 Botan 对密码进行哈希处理。我尝试使用以下代码测试该库:
#include <iostream>
#include <string>
#include <botan/argon2.h>
#include <botan/system_rng.h>
int main() {
Botan::System_RNG rng;
std::string password = "cool_password";
std::string generated_hash = Botan::argon2_generate_pwhash(password.c_str(),
password.length(), rng, 1, 4000, 1); // crash occurs here
std::cout << generated_hash << "\n";
}
但代码要么打印垃圾数据,要么给我一个运行时错误:
Unhandled exception at 0x00007FFEF11825E0 (ucrtbased.dll) in app.exe: 0xC0000005: Access violation reading location 0x0000000100000000.
我应该怎么办?使用 Botan::generate_bcrypt() 等其他散列方法也会导致相同的错误。