MD5 string hashing - via a WCF service

DZone 's Guide to

MD5 string hashing - via a WCF service

· ·
Free Resource

I was working on a Flickr application for Windows Phone 7 and one of the required elements for it was the necessity to generate a signature, that basically is a MD5 hash of a string. Instead of working directly with hashing inside the application, I decided to take this task one level up and set it up as a web service.

So now I have a WCF service that can hash strings, hosted at:


The services subdomain is there because I plan on working on some more utility services that will together build my own service hub. But for now it is just a WCF sandbox for me.

The service can be called from a .NET application by adding a service reference:


Once prompted, just use the service URL I mentioned above:


The whole service is built around IHash that has a single method defined – GetHashString:


That method returns a hashed string, so in your application you can call it asynchronously like this:

MD5HashService.HashClient client = new MD5HashService.HashClient();
client.GetHashStringCompleted +=
new EventHandler<MD5HashService.GetHashStringCompletedEventArgs>(client_GetHashStringCompleted);

Note that I am referencing client_GetHashStringCompleted as the event handler that will be triggered when the asynchronous operation is completed. In my case (testing purposes), I simply display the result of the request:

void client_GetHashStringCompleted
(object sender, MD5HashService.GetHashStringCompletedEventArgs e)

That way, you can use this service in your .NET application if you don’t want to manage MD5 string hashing inside your application (e.g. you have a mobile application).

I created this as a “just-for-fun” project, but I would appreciate any feedback regarding this service. Let me know if you encounter any issues or find bugs, and I will try fixing them in a timely manner.

You can download the source code for this service here.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}