【问题标题】:Crypto++ : Hash generation hangs on windows 10Crypto++:哈希生成在 Windows 10 上挂起
【发布时间】: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 头文件。

谢谢, 问候

【问题讨论】:

    标签: c++ crypto++ sha-3


    【解决方案1】:

    换行

    SHA3 digestAlgo = SHA3_256();
    

    SHA3_256 digestAlgo;
    

    【讨论】:

    • 我花了几分钟才看到。一切都很完美,没有理由开始繁重的运行,除了变量。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-23
    • 2018-10-14
    相关资源
    最近更新 更多