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(“Sinpin”));
خروجی
e140088b10c4f19588ed3624e2b3c463