به کمک کدهای زیر میتوانیم رمزهای ثبت شده توسط کاربر را برای امنیت بیشتر تبدیل به کدهای هش کنیم

using System.Security.Cryptography;

public static string CreateMD5(string input)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
return sb.ToString();

}
}

خروجی گرفتن

textBox2.Text = "MD5 = " + CreateMD5(textBox1.Text);