typedef struct {
ULONG i[2];
ULONG buf[4];
unsigned char in[64];
unsigned char digest[16];
} MD5_CTX;
//定义函数指针
typedef void (WINAPI* PMD5Init)(MD5_CTX* context);
typedef void (WINAPI* PMD5Final)(MD5_CTX* context);
typedef void (WINAPI* PMD5Update)(MD5_CTX* context, const unsigned char* input, unsigned int inlen);
void GetFileMD5(CString fileName, LPWSTR strBuf)
{
FILE* ff;
unsigned long nSize = 1024;
char* rBuff = (char*)malloc(sizeof(char) * nSize);
unsigned long rCount = 0;
MD5_CTX context;
//加载微软提供MD5计算的dll文件
HMODULE hdll = LoadLibrary(L"Cryptdll.dll");
PMD5Init m_pFuncMD5Init = NULL;
PMD5Final m_pFuncMD5Final = NULL;
PMD5Update m_pFuncMD5Update = NULL;
if (hdll == NULL)
{
printf("load dll Cryptdll faild\n");
exit(1);
}
//获得相应的函数地址
m_pFuncMD5Init = (PMD5Init)GetProcAddress(hdll, "MD5Init");
C语言 使用Cryptdll计算文件md5值
最新推荐文章于 2024-09-08 20:29:34 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)