Search Wiki:
Resource Page Description
An implementation of the MD5 cryptographic hashing algorithm for Silverlight. This class consists of fully transparent C# code, suitable for use in any managed Silverlight application. This class also works without modification on the full .NET runtime without modification, if the built in MD5CryptoServiceProvider does not meet your needs.

** A note on the security of the MD5 algorithm **

MD5 is generally considered insecure for use in cryptographic operations. If possible, you should be using a more modern algorithm for your software, such as SHA2 for cryptographic hashing, or one of the CRC methods for transmission hashes. Nevertheless, it’s sometimes necessary for backwards compatibility. If this is the initial release of a Silverlight application, please don’t use MD5, use one of the ones above.

Usage

Simply add the MD5.cs file to your existing Silverlight or .NET project within Visual Studio. Because it’s a static class, simply call the function MD5Core.GetHash(argument), providing either a string or byte array as the first argument. The return value is a byte array containing the MD5 hash of the input object.

You can also use MD5Core.GetHashString(argument), with either a string or byte array, and get back a string consisting of the ASCII printable hex value.

For an MSDN-style reference, see the MD5Core or MD5Managed class reference.

Advanced Usage

There is a reference executable suitable for use with the full .NET framework included as MD5Test.cs. This should be compiled with MD5.cs and MD5Managed.cs, and implements performance tests and test vectors for the MD5 implementation. It is also available as a precompiled binary for .NET 2.0 as MD5Test.exe. Usage is:

                MD5Test.exe [<string to hash>|-v|-t]
                        -v      Run test vectors
                        -t      Run performance test
Last edited Dec 8 2008 at 3:20 AM  by ReidB, version 9
Comments
carstenh wrote  Apr 8 2009 at 4:32 AM  
The code should not be used. It is buggy. E.g.
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
hashes to C23F8EE9C9375BD69ADA95AF3E706267. The correct value (using MD5CryptoServiceProvider) is A9FDC2DBC13C61B68C7EBF5136F5ED26.

ReidB wrote  Jun 4 2009 at 8:36 PM  
Thank you for your bug report. This issue has been fixed in the v2 release, now available. Additionally, v2 adds better stream support for use on large data sets with minimal overhead. Please upgrade to v2 as soon as possible.

AnnaT wrote  Aug 30 2010 at 1:04 PM  
Still there is a problem with strings (or last portion) of 56 chars long. Line 109 must be
if (cbSize < 56)

dvision wrote  Jun 28 2011 at 10:22 AM  
Thanks AnnaT, this was wrong indeed and fixed by your solution..
Why wasn't v2 updated to v3?

Lokesh wrote  Mar 14 2012 at 6:38 AM  
These two files MD5Core and MD5Managed can not help you, Please do not waste your time to experiment with these. Output is totally different from MD5Hash.

clovett wrote  Jan 9 at 6:42 AM  
See http://www.jeff.wilcox.name/2008/03/silverlight-2-md5/

Updating...
Page view tracker