/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <wchar.h>

#include <openssl/md4.h>

void digest(char *buf, size_t buflen, char *md)
{
    MD4_CTX ctx;
    MD4_Init(&ctx);
    MD4_Update(&ctx, buf, buflen);
    MD4_Final(md, &ctx); 
}

int main()
{
    int i;
    char tmp[24],res[16];
    digest((char*)L"password", 2*wcslen(L"password"), tmp);
    wcscpy((wchar_t*)(tmp + 16), L"user");
    digest(tmp, sizeof(tmp), res);
    for(i = 0; i < 16; i++)
    {
        printf("%02x", (unsigned char)res[i]);
    }
    printf("\n");
    return 0;
}

/* gcc md4.c -o md4.exe -lcrypto */
