using System;
using System.Security.Cryptography;
using System.Text;..................................................................
static string GetMd5Hash(string textToHash)
{
MD5CryptoServiceProvider md5CryptoServiceProvider = new MD5CryptoServiceProvider();
byte[] data = md5CryptoServiceProvider.ComputeHash(Encoding.Default.GetBytes(textToHash));
StringBuilder sbHashedCode = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sbHashedCode.Append(data[i].ToString("x2"));
}
return sbHashedCode.ToString();
}
static bool verifyMd5Hash(string plainText, string hashedValue)
{
return StringComparer.OrdinalIgnoreCase.Compare(GetMd5Hash(plainText), hashedValue) == 0 ? true : false;
}This Code snippet for Hashing a plain text in to MD5Hashing and comparing if two hashed codes are same.
