c++ - 在 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 无法正常工作。
推荐阅读
- flutter - 出现不同的屏幕高度问题,MediaQuery.of(context).size.height / value 不起作用?颤振界面
- flutter - Flutter tabController 监听器在滑动时响应缓慢
- javascript - 只检查一次浏览器宽度和触发事件
- ios - 我正在尝试安装 Opencv pods 安装错误
- java - HarmonyOS for Android OS 中的 onDraw 的替代功能是什么?
- javascript - 如何在 Vue.js 项目的服务中延迟加载 service.js 文件或字体文件?
- apache-spark - 当条件无法正常工作时 - pyspark
- database - 有没有办法在 GraphQL 中快速将所有数据从一个表复制到另一个表?
- android - Viewpager2 中的片段有一个活动,但上下文为空
- react-native - Expo SQLite 渲染无限数量的组件