(.NET) MD5CryptoServiceProvider and (Win32 CSP) CryptHashData/CryptGetHashParam return two different

  • Thread starter Kerem Gümrükcü
  • Start date
K

Kerem Gümrükcü

Hi,

this is not a pure MFC/VC++ question but my apologizes at first.
Well, i have a application that calculates the hash for a file. You
can request a CALG_SHA1 or a CALG_MD5 for the File. The
Process of Hash Calculation works fine, but i get two totally different
Hash values for e.g. kernel32.dll when i try to get the hash with the
following steps compared to the managed .NET MD5 Provider.

The Hash "24d244d0a15ab17885d578d1c54d5294" comes from
the following steps:
CryptAcquireContextW
CryptCreateHash
CryptHashData
CryptGetHashParam, with HP_HASHSIZE
CryptGetHashParam, with HP_HASHVAL

The Hash "8eea8280a1e0e794edfccad3721c7cab"
comes from the .NET CSP "MD5CryptoServiceProvider"
and seems to be the right one (compared to other MD5 tools),
but why does the Windows API CSP return crap?

I can post code if you like (its a little bit to long to post here), but
the code works with no problems,...

Here is a screenshot if you like:
http://entwicklung.junetz.de/pics/verinfo_hash.jpg

I am a little confused,...

Regards

Kerem



--
 
K

Kerem Gümrükcü

Dude, i am god-damn stupid, i am the most stupid
human being on earth, i swear to god! I forget to read
the file content to the memory i allocated with VirtualAlloc.
Smack me,...punish me, hit me....

I did a raw look at the memory and then i asked myself why
everthing is full of zeros (MEM_COMMIT). And then it HIT me
like a baseball-bat.

Damn! OMG!!!!

Regards

Kerem

--
 
K

Kerem Gümrükcü

Hi Mark,

this happens when you try to make the code perfect.
You forget the data ,... :-D

SMACK ME!!! :p

Regards

Kerem

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top