MD5 Implementation in C#

Introduction :
This was my first piece of code in C# . It is a very simple implementation of MD5 message digest algorithm( RFC 1321) for generating hash values. The code is based  on .net framework 1.1. You can use the windows form interface or console interface to quickly get MD5 hash values. You can also add it as reference to you project use it as a class library. Its quite light weight, and can be compiled for compact framework.

you can download the source code here : DOWNLOAD MD5 IMPLEMENTATION


19 responses to “MD5 Implementation in C#

  1. Thanks a lot for this, I’ve been strugling a couple of weeks to get some C# MD5 implementation for analysis and at least I found one here!

    Really nice, thanks a lot.

  2. many thanks for this code! 😉

  3. thank you so much …

  4. silvertongue

    thank you for the code, it really helps!!!

  5. Thanks from me, too. God bless.

  6. using System;
    using System.Security.Cryptography;
    using System.Text;

    public class MD5
    public static string MD5(string password)
    var textBytes = Encoding.Default.GetBytes(password);
    var cryptHandler = new MD5CryptoServiceProvider();
    var hash = cryptHandler.ComputeHash(textBytes);
    var ret = “”;
    foreach (var a in hash)
    ret += a.ToString(“x2”);
    return ret;

  7. Hi Mr. Mahmood,
    i need a MD5 implementation for a silverlight project and found your code.
    Under what kind of license did you publish this code – can it be used in a compiled commercial application?
    thank you for more info

  8. Thanks, I’m using this in my Silverlight project and it works perfectly!

  9. I need to write the MD5 implementation in Silverlight 3, which namespace do I use to get the required classes.


  10. I ‘m in need of the code for my final year project. thanks for the code , bt can i get a simplified code .. either in c# or

  11. Pingback: MD5 hashes in C# – benchmark and speed ​​optimization |

  12. Pingback: MD5 Hashes in C# erzeugen – Benchmark und Geschwindigkeitsoptimierung |

  13. Good day
    Can you briefly comment on the work ?
    Difficult to understand…

  14. Good code. That’s what I’m looking for. Thanks man.

  15. thank u very much

  16. Thank you very much for sharing this code. It worked perfectly and save me hours!

  17. Hello there.
    There are the classes MD5ChangingEventArgs and MD5ChangedEventArgs.
    The code where you declare the new local variable byte[] NewData
    inside the initializers…
    I believe you intended to reintialize the global variable with the same name declared inside these classes. But this way you can not access the changes because that local variable hides the global one.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s