0

我正在尝试使用 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() 等其他散列方法也会导致相同的错误。

4

1 回答 1

1

经过 4 小时痛苦的故障排除和一遍又一遍地使用不同的编译器重建库后,我发现如果 Visual Studio 中的“解决方案配置”未设置为“发布”而不是“调试”,Botan 无法正常工作。

于 2021-02-08T18:14:53.157 回答