Creating MD5 hash strings in Silverlight v1.1

24 October 2007

In the Silverlight v1.1 Alpha CTP bits, there's only the APIs and libraries that are necessary and useful for the rich web client. While working on implementing the Flickr web services API within a .NET-enabled Silverlight sample application, I found that the MD5 algorithm isn't available within the cryptography APIs. Like many REST-based web services, the simple Flickr API uses MD5 along with a form of "signing" with a known secret. A quick search on the web revealed a nice managed code implementation of MD5 that doesn't use any unsafe calls, so it was a cinch to get it running within my managed app. Thought I'd share the file here: Md5.cs. The excellent MD5 implementation was created by the GL Conseil/Flow Group SAS; they did this work to enable MD5 within the Compact Framework 2.0. Calling the function is very simple: MD5CryptoServiceProvider.GetMd5String("This is what I want a hash of!"); Hope this helps! Download "Md5.cs" as text

Jeff Wilcox is a Software Engineer at Microsoft in the Open Source Programs Office (OSPO), helping Microsoft engineers use, contribute to and release open source at scale.

comments powered by Disqus