using System.Security.Cryptography;
public static string EncodePassword(string originalPassword)
{
Byte[] originalBytes;
Byte[] encodedBytes;
MD5 md5;
// Conver the original password to bytes; then create the hash
md5 = new MD5CryptoServiceProvider();
originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
encodedBytes = md5.ComputeHash(originalBytes);
// Bytes to string
return System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
}