Thank goodness for reference implementations [Low-overhead .NET MD5 implementation (source code and tests) works great on Silverlight!]

This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of

See you there!

Comments (5)
  1. You’ve been kicked (a good thing) – Trackback from

  2. Delay's Blog says:

    Kind reader Gregor Zurowski contacted me over the weekend to let me know that he was using my free CRC-32

  3. LeeCarter says:

    OK, I can see that this is producing the same hash for known data as I get in C++ from using a sequence of:





    The CryptAcquireContext() and CryptCreateHash() are setup operations, the CryptHashData() adds data to be processed and finally CryptGetHashParam() gives the 16 byte hash value.

    With the C++ mechanism I can repeatedly call CryptHashData() to add more data to be hashed.

    With this and all the C# implementations I have seen they all appear to need all the data at once.  

    I need to process a large volume of data and get a MD5 hash code for it.

    Is there a way I can feed the data in a chunk at a time or do I have to buffer it all up and throw it in to ComputeHash() as a single operation?

  4. David Anson says:


    If you have a look at the MD5ManagedTests.cs file in the ZIP linked to by this post, I demonstrate three ways of using HashAlgorithm. You’re interested in the Initialize/TransformBlock/TransformFinalBlock pattern which processes arbitrarily-sized chunks of data. You just pass in whatever you’ve got until you’re done, then you retrieve the computed hash value when it’s all done. In addition to doing this in my test code, I follow this pattern in my ComputeFileHashes suite (also linked to by this post).

    Hope this helps!

  5. LeeCarter says:


    Thank you for your response.  I’ve look at the test code in more detail now than I did at first and yes it will fit nicely into the scenario I want to try it in.

Comments are closed.