System.Security.Cryptography.MD5CryptoServiceProvider

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

According to MS Knowledge Base article 307020, we have to instantiate a new
instance of the MD5CryptoServiceProvider class for every new hash value we'd
like to compute (from step 6 of the article).

I'm wondering if I could reuse the same object to compute multiple hash
values by using the Init() method of the class inbetween calls of
ComputeHash().

Comments/suggestions please.

Thanks.
 
I'm not convinced the article is correct.
ComputeHash is a base-class method that first calls HashCore then calls
HashFinal, and then also calls Initialize again.
From looking at ILDASM on MD5CryptoServiceProvider, the Initialize method
appears to recreate the underlying unmanaged hash handle.
So to answer your question, Initialize is already being called for you.
Also, the CanReuseTransform property returns True. I really don't know why
the article specifies you would need a new instance. If anyone has more
info, feel free to chime in, but off the top of my head, I can't see why you
would.

-Rob Teixeira
 
Back
Top