微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Botan 上使用 Argon2 生成哈希导致垃圾数据和 0xC0000005:访问冲突读取位置 0x0000000100000000

如何解决在 Botan 上使用 Argon2 生成哈希导致垃圾数据和 0xC0000005:访问冲突读取位置 0x0000000100000000

我正在尝试使用 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 小时痛苦的故障排除并一遍又一遍地使用不同的编译器重建库后,我发现如果 Visual Studio 中的“解决方案配置”未设置为“发布”而不是“调试”,则 Botan 无法正常工作.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。