#include
/ Data structure for MD5 (Message-Digest) computation / typedef struct { ULONG i[2]; / number of bits handled mod 2^64 / ULONG buf[4]; / scratch buffer / unsigned char in[64]; / input buffer / unsigned char digest[16]; / actual digest after MD5Final call / } MD5_CTX;
#define MD5DIGESTLEN 16
#define PROTO_LIST(list) list
/*
- MTS: Each of these assumes MD5_CTX is locked against simultaneous use. / typedef void (WINAPI PMD5Init) PROTO_LIST ((MD5_CTX )); typedef void (WINAPI PMD5Update) PROTO_LIST ((MD5_CTX , const unsigned char , unsigned int)); typedef void (WINAPI PMD5Final )PROTO_LIST ((MD5_CTX ));
PMD5Init MD5Init = NULL; PMD5Update MD5Update = NULL; PMD5Final MD5Final = NULL;
const char Hex2ASC(const BYTE Hex, int Len) { static char ASC[4096 * 2]; int i;
for (i = 0; i < Len; i++)
{
ASC[i * 2] = "0123456789ABCDEF"[Hex[i] >> 4];
ASC[i * 2 + 1] = "0123456789ABCDEF"[Hex[i] & 0x0F];
}
ASC[i * 2] = '\0';
return ASC;
}
int main() { MD5_CTX ctx; unsigned char buf[10] = “Xiaozhou”; HINSTANCE hDLL;
if ( (hDLL = LoadLibrary("advapi32.dll")) > 0 )
{
MD5Init = (PMD5Init)GetProcAddress(hDLL,"MD5Init");
MD5Update = (PMD5Update)GetProcAddress(hDLL,"MD5Update");
MD5Final = (PMD5Final)GetProcAddress(hDLL,"MD5Final");
MD5Init(&ctx;);
MD5Update(&ctx;,buf,8);
MD5Final(&ctx;);
printf("%s \n",Hex2ASC(ctx.digest,16));
}
return 0;
}