gpt4 book ai didi

c++ - 有sha256的头文件吗?

转载 作者:太空宇宙 更新时间:2023-11-04 05:44:30 25 4
gpt4 key购买 nike

我使用的是 Linux,我只需要 sha-256 的现有 header ;我尝试了很多代码块,但没有一个起作用。

#include <iostream>
#include "sha256.h"

using namespace std;

int main(int argc, char *argv[])
{
string input = "abc";
string output1 = sha256(input);

cout << "sha256('"<< input << "'):" << output1 << endl;
return 0;
}

填充哈希输入:

0x616263800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000018

如何添加sha256.h

最佳答案

不在 STL 中。您可以使用您选择的库(例如 OpenSSL):

#include <openssl/sha.h>

void foo()
{
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, str.c_str(), str.size());
SHA256_Final(hash, &sha256);
}

我猜你的例子来自 here 。如果是这种情况,您只需从网站复制/粘贴文件并使用您的项目构建它们即可。

关于c++ - 有sha256的头文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25544604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com