- //第一种加密
- string str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("密码", "MD5");
- //第二种加密
- //引入命名空间
- using System.Text;
- using System.Security.Cryptography;
- MD5 md5 = MD5CryptoServiceProvider.Create();
- byte[] data = Encoding.UTF8.GetBytes("密码");
- byte[] newdata = md5.ComputeHash(data);
- string str = BitConverter.ToString(newdata);
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)