From: http://www.fzitshow.com/redirect.php? Tid = 11971 & goto = lastpost
# Include <string. h>
# Include <stdlib. h>
# Include <OpenSSL/md5.h>
// Function prototype;
// Void md5_init (md5_ctx * C );
// Void md5_update (md5_ctx * C, const void * data, unsigned long Len );
// Void md5_final (unsigned char * MD, md5_ctx * C );
Int main (INT argc, char * argv [])
{
Char password [128] = {0 };
Md5_ctx X;
Int I = 0, Len;
Char * out = NULL;
Unsigned char d [16];
Unsigned char TMP [128] = {0 };
If (argc! = 2 ){
Printf ("Usage: % S <message>/N", argv [0]);
Return-1;
}
Strcpy (password, argv [1]);
Md5_init (& X );
Md5_update (& X, (char *) password, strlen (password ));
Md5_final (D, & X );
Out = (char *) malloc (35 );
Memset (Out, 0x00, 35 );
Strcpy (Out, "$1 $ ");
Printf ("MD5 (/" % S/") =", password );
For (I = 0; I <16; I ++ ){
Sprintf (out + (I * 2), "% 02x", d [I]); // convert to 32 bits
}
Out [32] = 0;
Printf ("% s/n", out );
Return 0;
}
// Call libcrypt. So:/usr/lib/libcrypt. So during compilation
Gcc-O MD5 md5.c-lcrypto
// Execute:
./MD5. 123
// Possible result: 202cb962ac59075b964b07152d234b70