find a location for property in a new city

Thursday, 8 September 2011

MD5 encryption in .NET

There is not set up needed for this one.

MD5 hash encryption

public static string Md5Encryption(string dataToEncrypt)
{
    var bytes = Encoding.Default.GetBytes(dataToEncrypt);
    using (var md5 = new MD5CryptoServiceProvider())
    {
        var cipher = md5.ComputeHash(bytes);
        return Convert.ToBase64String(cipher);
    }
}

Follow britishdev on Twitter

4 comments:

  1. hi, i am new in security concepts of .net.

    But i want to learn it

    Your articles are great but i got problem to decrypt the string that has been encrypted by MD5.

    Could you also post this how could i decrypt the string that is encrypted by MD5

    ReplyDelete
  2. You cannot decrypt MD5 hashes. It is one way encryption. You'd want RSA or Triple DES (or something else) if you want encryption and decryption

    ReplyDelete
  3. Thanks for this information, it was very helpful. Keep up the good work.
    pgp desktop

    ReplyDelete
  4. There are many different types of encryption used in security of the computers but one that is most strong and efficient is the MD5 Hash. Don't ever forget to include a reference to 'System.Security.Cryptography' in your project, it's a must.

    ReplyDelete