DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

MD5 string hashing - via a WCF service

Denzel D. user avatar by
Denzel D.
·
Nov. 20, 11 · · Interview
Like (0)
Save
Tweet
4.71K Views

Join the DZone community and get the full member experience.

Join For Free

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:

http://services.dennisdel.com/md5/MD5HashService.svc

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:

image

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

image

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

image

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);
client.GetHashStringAsync("MyString"); 

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)
{
Debug.WriteLine(e.Result);
} 

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.

Windows Communication Foundation Web Service Strings Data Types mobile app

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Maven Tutorial: Nice and Easy [Video]
  • Modern REST API Design Principles and Rules
  • What SREs Can Learn From the Atlassian Nightmare Outage of 2022
  • How to Leverage Method Chaining To Add Smart Message Routing in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo