Cor*_*ory 16 c++ encryption hash
可能重复:
cpp中的sha1函数(C++)嗨,
我只是在寻找一个函数来计算字符串的sha1哈希并返回结果.
Zaf*_*ffy 39
不是内置的.试试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;
}
Run Code Online (Sandbox Code Playgroud)
链接-lssl,这将暗示-lcrypto.如果您要静态链接,则可能需要链接两者.