MSDN Archive Home
Help and FAQs
Silverlight MD5 implementation
All Resource Updates
Change History (all pages)
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
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.
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
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
Dec 8 2008 at 3:20 AM
, version 9
Apr 8 2009 at 4:32 AM
The code should not be used. It is buggy. E.g.
hashes to C23F8EE9C9375BD69ADA95AF3E706267. The correct value (using MD5CryptoServiceProvider) is A9FDC2DBC13C61B68C7EBF5136F5ED26.
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.
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)
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?
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.
Jan 9 at 6:42 AM
Sign in to add a comment
Silverlight MD5 Implem...
Mon Sep 19 2011 at 7:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.