void ShaTest()
{
CHAR *lpStr = "1234567890abcdef1234567890abcdef优雅人生www.dllhook.com";
CHAR szSha[32] = {0};
int i = 0;
CHAR *lpStr_ = lpStr;
printf("明文:%s\n", lpStr);
sha _sha;
shs_init(&_sha);
while(*lpStr != 0)
shs_process(&_sha, *lpStr++ );
shs_hash(&_sha, szSha);
printf("SHA1:");
for (i = 0; i < 20; i++)
{
if (szSha[i] == 0)
break;
printf("%.2X", (unsigned char)szSha[i]);
}
printf("\n");
lpStr = lpStr_;
sha256 _sha256;
shs256_init(&_sha256);
while(*lpStr != 0)
shs256_process(&_sha256, *lpStr++ );
shs256_hash(&_sha256, szSha);
printf("SHA256:");
for (i = 0; i < 32; i++)
{
if (szSha[i] == 0)
break;
printf("%.2X", (unsigned char)szSha[i]);
}
printf("\n");
}
// 输出:
明文:1234567890abcdef1234567890abcdef优雅人生
www.dllhook.com
SHA1:FC71055259AC533B1BAD8C408FE56D43ECC1290F
SHA256:CE95C3D366BF87B6776C071AF2053CB07264D29A5C0729FA138379AB2B358E51
发表评论