一:
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("要加密的字符串", "MD5");//返回的就是加密後的字符串
此方法要引入System.Web;的類庫才能用
二:
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] b = md5.ComputeHash(Encoding.UTF8.GetBytes(textBox1.Text));
string s = "";
for (int i = 0; i < b.Length; i++)
{
s += b[i];
}
label2.Text = s;//這就是返回的加密後的字符串
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("要加密的字符串", "MD5");//返回的就是加密後的字符串
此方法要引入System.Web;的類庫才能用
二:
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] b = md5.ComputeHash(Encoding.UTF8.GetBytes(textBox1.Text));
string s = "";
for (int i = 0; i < b.Length; i++)
{
s += b[i];
}
label2.Text = s;//這就是返回的加密後的字符串