c++ - Crypto++:哈希生成在 Windows 10 上挂起
问题描述
我有以下简单的程序:
#include <cryptlib.h>
#include "sha.h"
#include <sha3.h>
#include <filters.h>
#include <hex.h>
#include <beast/core/detail/base64.hpp>
using namespace CryptoPP;
using namespace boost::beast::detail::base64;
int main(int argc, char** argv) {
if (argc < 2) {
std::cout << "missing argument 1 : password";
return 0;
}
std::string password = std::string(argv[1]);
byte digest[SHA3_256::DIGESTSIZE];
SHA3 digestAlgo = SHA3_256();
std::cout << "going to calculate the digest\n";
digestAlgo.Update((const byte*) password.data(), password.size());
std::cout << "updated...\n";
digestAlgo.Final(digest);
std::cout << "calculated the digest\n";
char* b64encodedHash = (char*)malloc(sizeof(byte)*1000);
encode(b64encodedHash, digest, sizeof(byte)*1000);
std::cout << "password hashed : " << b64encodedHash << "\n";
return 1;
}
当我运行它时,在命令行上输出文本:“要计算摘要”并且程序不会继续。它挂起。有谁知道为什么?我正在尝试遵循 Crypto++ wiki 上的示例,这与他们的非常相似。在 Final call 我想对摘要进行 base64 编码之后,您可以删除该部分,它使用 boost 头文件。
感谢和问候
解决方案
换行
SHA3 digestAlgo = SHA3_256();
到
SHA3_256 digestAlgo;
推荐阅读
- asp.net-mvc - 无法在 gulp 构建中捆绑 Angular 应用程序
- spring - @RestController 返回空白
- laravel - Laravel Eloquent 可以递增 ($collection->increment('field')) 失败吗?
- java - Azure SQL:连接的错误代码是关闭异常的
- vbscript - 理解这个比较函数(VBScript)
- java - DOM4J utf-8 编码变音符号(Ä,ü,ß) 不正确
- chart.js - ChartJS - 自定义 Y 轴上的刻度/标签
- mysql - 使用带有或的选择插入
- reactjs - Ant Design & Webpack 不加载 css
- android - 了解 Android Vitals 在 Play 商店控制台中提供的 ANR 日志