#include <openssl/md5.h>
void hexifyLower(char* obuf, const unsigned char* ibuf, int len)
{
unsigned char l, h;
while (len != 0)
{
h = (*ibuf) / 16;
l = (*ibuf) % 16;
if (h < 10)
*obuf++ = '0' + h;
else
*obuf++ = 'a' + h - 10;
if (l < 10)
*obuf++ = '0' + l;
else
*obuf++ = 'a' + l - 10;
++ibuf;
len--;
}
}
{
unsigned char outArr[16] = { 0 };
MD5_CTX mdContext;
MD5_Init(&mdContext);
MD5_Update(&mdContext, data.getBytes(), static_cast<int>(data.getSize()));
MD5_Final(outArr, &mdContext);
char outBuff[33] = { 0 };
hexifyLower(outBuff, outArr, 16);
auto md5Str = std::string(outBuff, 32);
}
openssl计算md5
最新推荐文章于 2024-01-05 11:07:40 发布