- 3
- 0
- 约2.55千字
- 约 3页
- 2024-02-03 发布于上海
- 举报
再次利用
再次利用openssl来计算sha1,sha224,sha256,sha384,
sha512
请按照之前博文的介绍配置openssl环境。代码如下:
[cpp]viewplaincopy
1.
1.
2.
3.
4.
5.
6.
7.
8.
9.
#includeiostream
#includeopenssl/sha.h#includeopenssl/crypto.h
//OPENSSL_cleanse
#pragmacomment(lib,libeay32.lib)
#pragmacomment(lib,ssleay32.lib)
usingnamespacestd;
//在本程序中,可以注释掉这句
constchar*orgStr=hello;//待哈希的串
//打印前,有必要转换
voidprintHash(unsignedchar*md,intlen)
12.{
13.
14.
15.
16.
17.
18.
19.
20.}21.
inti=0;
for(i=0;ilen;i++)
{
printf(%02x,md[i]);
}
printf(\n);
22.voidmyHash1()
23.{
24.
25.
26.
27.
28.
29.
30.
31
原创力文档

文档评论(0)