Click here to Skip to main content
15,891,846 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionregex Pin
aldo hexosa25-Apr-07 16:31
professionalaldo hexosa25-Apr-07 16:31 
AnswerRe: regex Pin
Hamid_RT25-Apr-07 18:28
Hamid_RT25-Apr-07 18:28 
AnswerRe: regex Pin
Stephen Hewitt25-Apr-07 19:44
Stephen Hewitt25-Apr-07 19:44 
QuestionProblem with ClassWizard Pin
Reagan Conservative25-Apr-07 10:31
Reagan Conservative25-Apr-07 10:31 
AnswerRe: Problem with ClassWizard Pin
Nibu babu thomas25-Apr-07 17:30
Nibu babu thomas25-Apr-07 17:30 
AnswerRe: Problem with ClassWizard Pin
David Crow25-Apr-07 17:47
David Crow25-Apr-07 17:47 
GeneralRe: Problem with ClassWizard Pin
Reagan Conservative26-Apr-07 4:17
Reagan Conservative26-Apr-07 4:17 
QuestionMD5 hash Pin
Andy H25-Apr-07 10:00
Andy H25-Apr-07 10:00 
I am trying to hash a password using MD5 to get the resultant digest. These are taken from the example I am following (which is from a trusted authority):

• First get the bytes of the original password, assuming a "Latin-1" encoding. For the password "Baltimore1," these bytes are: 66 97 108 116 105 109 111 114 101 49 44 (i.e. the value of "B" is 66, "a" is 97, etc).
• Then get the MD5 hash of these bytes. MD5 is a standard, public algorithm. Once again, for the password "Baltimore1," these bytes work out as: 223 238 161 24 62 121 39 143 115 167 51 163 245 231 226 94
• Finally, create the new password by forming a string whose Latin-1 encoding is the bytes from the previous step. For the "Baltimore1," password, if this is string is written to the screen, it looks like: ßî¡_>y'?s§3£õçâ^(i.e. the 62 above is a ">", the 121 is a "y", etc).


However, whenever I perform the hash I don't get the same result, I get:

6, 156, 90, 148, 160, 205, 176, 131, 162, 231, 168, 208, 232, 207, 90, 241

and string: œZ” Í°ƒ¢ç¨ÐèÏZñ

The code extract I am using is:

...<br />
unsigned char* pszPwd = simple_digest( "md5", "Baltimore1", strlen("Baltimore1"), &len );<br />
...<br />
<br />
unsigned char* simple_digest( char* alg, char* buf, unsigned int len, unsigned int* olen )<br />
{<br />
	const EVP_MD*	m;<br />
	EVP_MD_CTX		ctx;<br />
	unsigned char*	ret;<br />
<br />
	OpenSSL_add_all_digests();<br />
<br />
	if ( !( m = EVP_get_digestbyname( alg ) ) )<br />
	{<br />
		return NULL;<br />
	}<br />
<br />
	if ( !(ret = (unsigned char*)malloc(EVP_MAX_MD_SIZE)) )<br />
	{<br />
		return NULL;<br />
	}<br />
<br />
	EVP_DigestInit( &ctx, m );<br />
	EVP_DigestUpdate( &ctx, buf, len );<br />
	EVP_DigestFinal( &ctx, ret, olen );<br />
<br />
	return ret;<br />
}


This is using the OpenSSL library. I tried to do the hash with completely seperate code that performs a MD5 hash and it came to the same result!

Can anyone PLEASE point me to where I am going wrong?
AnswerRe: MD5 hash Pin
cmk25-Apr-07 13:19
cmk25-Apr-07 13:19 
AnswerRe: MD5 hash Pin
cp987625-Apr-07 15:26
cp987625-Apr-07 15:26 
QuestionHow to implement Complex exponential functions ??? Pin
Hazardcoder25-Apr-07 9:45
Hazardcoder25-Apr-07 9:45 
AnswerRe: How to implement Complex exponential functions ??? Pin
JudyL_MD25-Apr-07 9:52
JudyL_MD25-Apr-07 9:52 
GeneralRe: How to implement Complex exponential functions ??? Pin
Hazardcoder25-Apr-07 10:01
Hazardcoder25-Apr-07 10:01 
GeneralRe: How to implement Complex exponential functions ??? Pin
JudyL_MD25-Apr-07 10:04
JudyL_MD25-Apr-07 10:04 
GeneralRe: How to implement Complex exponential functions ??? Pin
Hazardcoder25-Apr-07 10:48
Hazardcoder25-Apr-07 10:48 
AnswerRe: How to implement Complex exponential functions ??? Pin
cp987625-Apr-07 12:30
cp987625-Apr-07 12:30 
AnswerRe: How to implement Complex exponential functions ??? Pin
Goggelmoggel26-Apr-07 7:19
Goggelmoggel26-Apr-07 7:19 
QuestionCrypt API Pin
koumodaki25-Apr-07 9:20
koumodaki25-Apr-07 9:20 
AnswerRe: Crypt API Pin
Mark Salsbery25-Apr-07 9:27
Mark Salsbery25-Apr-07 9:27 
GeneralRe: Crypt API Pin
koumodaki25-Apr-07 9:34
koumodaki25-Apr-07 9:34 
GeneralRe: Crypt API Pin
Mark Salsbery25-Apr-07 9:38
Mark Salsbery25-Apr-07 9:38 
GeneralRe: Crypt API Pin
koumodaki25-Apr-07 9:47
koumodaki25-Apr-07 9:47 
GeneralRe: Crypt API Pin
Mark Salsbery25-Apr-07 9:54
Mark Salsbery25-Apr-07 9:54 
GeneralRe: Crypt API Pin
Mark Salsbery25-Apr-07 9:41
Mark Salsbery25-Apr-07 9:41 
GeneralRe: Crypt API Pin
koumodaki25-Apr-07 9:54
koumodaki25-Apr-07 9:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.