Google Answers Logo
View Question
 
Q: Problem creating MD5 hash, getting high ascii... ( No Answer,   0 Comments )
Question  
Subject: Problem creating MD5 hash, getting high ascii...
Category: Computers > Programming
Asked by: darlingm-ga
List Price: $5.00
Posted: 23 Mar 2005 08:37 PST
Expires: 23 Mar 2005 10:54 PST
Question ID: 499153
I'm trying to create a MD5 hash using "openssl/md5.h".  I'm either
missing something or am missing typecasting somewhere.

For an answer, I'm looking for what has to change in my code to get
the correct output.

--- BEGINNING OF CODE ---
unsigned char* input = (unsigned char*) strdup("thisIsATest");
cout << input << endl;
unsigned char buffer[1024];
MD5(input, 11, buffer);
cout << buffer << endl;
--- END OF CODE ---

prints out:
thisIsATest
<bunch of low and high ascii characters>

My understanding is that a MD5 hash should only use alpha-numerics. 
Why am I getting the high ascii?

I know the correct MD5 hash is: 791d8bf5f019659d15ce4fb04ad70316

Clarification of Question by darlingm-ga on 23 Mar 2005 10:54 PST
I figured it out ...

At least for the function I'm using, buffer has to be looked at
character by character.  For the output to be in the form I wanted,
the hexidecimal contents of the character need to be printed -- rather
than printing the character itself (which does an ASCII table lookup.)

For example, the first character printing out was a "y".  The value of
that character was hexidecimal 79, however by just printing it, a "y"
was printed because hexidecimal 79 is "y" in the ASCII table.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy