【发布时间】:2021-05-04 18:51: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 头文件。
谢谢, 问候
【问题讨论】: