Hash کردن یک رشته متنی با الگوریتم MD5:
using System.Security.Cryptography;
private string encryptString(string strToEncrypt)
{
UTF8Encoding ue = new UTF8Encoding();
byte[] bytes = ue.GetBytes(strToEncrypt);
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] hashBytes = md5.ComputeHash(bytes);
// Bytes to string
return System.Text.RegularExpressions.Regex.Replace
(BitConverter.ToString(hashBytes), "-", "").ToLower();
}
نحوه استفاده:
MessageBox.Show(encryptString("Softafzar.net"));
منبع:barnamenevis.org