/* Replace "dll.h" with the name of your header */
#include "md5.h"
#include "md5static.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>


DLLIMPORT void md5hash (char * buffer, unsigned int bufferlen, md5_hash_str_type hash_str) {
    unsigned int i;
    MD5_CTX context;
    unsigned char chunk[3];
    
    md5_hash_type digest;
    MD5Init(&context);
    MD5Update(&context, buffer, bufferlen);
    MD5Final(digest, &context);
    for (i = 0; i<16; ++i) {
        sprintf(chunk, "%02x", digest[i]);
        memcpy(hash_str+2*i, chunk, 2);
    }    
}    




BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;


      case DLL_PROCESS_DETACH:
        break;


      case DLL_THREAD_ATTACH:
        break;


      case DLL_THREAD_DETACH:
        break;
    }


    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
