System.Security.Cryptography.MD5CryptoServiceProvider md5CSP = new System.Security.Cryptography.MD5CryptoServiceProvider();//实例化md5
//获取要加密的字段,并转化为Byte[]数组
byte[] testEncrypt = System.Text.Encoding.Unicode.GetBytes(TextBox1.Text.Trim());//取到密码框里的值//加密Byte[]数组
byte[] resultEncrypt = md5CSP.ComputeHash(testEncrypt); //将加密后的数组转化为字段(普通加密) string testResult = System.Text.Encoding.Unicode.GetString(resultEncrypt);//作为密码方式加密
string EncrypPWD = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text.Trim(), "MD5");//加密完成EncrypPWD 是加密后的字段