> Date: Tue, 19 Jul 2005 04:30:03 -0700 (PDT) > From: kaustubh mendki <[EMAIL PROTECTED]> > > I am trying a simple program to get MD5 hash of > any string.The program is as follows: > > #include <stdio.h> > #include "openssl/md5.h" > > int main() > { > unsigned char var[]="k."; > unsigned char *op; > > op = MD5(var,strlen(var),NULL); > printf("\nHash= %s\tLen= %d",op, strlen(op)); > return 0; > } > > I compiled it with: gcc -lcrypto -o try try.c > The above code is returning empty hash with 0 length. > But with strings like ".", "k.a" this code is > working properly. > > Can anyone throw light on it?
Hashes are not printable C strings. They are byte arrays. Thus, printf and strlen will both fail. -- Ken Goldman [EMAIL PROTECTED] 914-784-7646 ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]