【发布时间】:2011-10-19 12:56:31
【问题描述】:
【问题讨论】:
-
C(以及在较小程度上,C++)并不以拥有大量内置功能而闻名。您可能会找到一个为此目的具有一个或多个函数的库。您使用哪种语言?
-
...我在这里,直接来自谷歌搜索!
标签: c++ encryption hash
【问题讨论】:
标签: c++ encryption hash
您需要使用库。 Boost 有这个功能。
【讨论】:
这是一个例子:http://www.codeproject.com/KB/recipes/csha1.aspx#csha1is
此外,this 线程已经解决了这个问题。他们有一个链接以获得进一步的帮助。看看吧。
【讨论】:
查看this post on Ubuntu Forums。他们建议查看libcrypt。
还有一个实现here,但我不确定许可证是什么。
【讨论】:
【讨论】:
不是内置的。试试 openssl 的加密库。
(https://www.openssl.org/source/)
(https://github.com/openssl/openssl/blob/master/include/openssl/sha.h)
(https://www.openssl.org/docs/man1.1.0/crypto/SHA1.html)
#include <openssl/sha.h>
int main()
{
const unsigned char str[] = "Original String";
unsigned char hash[SHA_DIGEST_LENGTH]; // == 20
SHA1(str, sizeof(str) - 1, hash);
// do some stuff with the hash
return 0;
}
与-lssl 链接,这将暗示-lcrypto。如果您是静态链接,则可能需要同时链接两者。
【讨论】:
-lcrypto 链接才能编译。例如。 gcc example.c -lcrypto.
libssl-dev。