Winform,c#进行MD5加密直接上步骤:c#
1.添加引用ide
2.在.NET选项卡中找到“System.Web”this
3.选中以后,点击“肯定”便可,此时会在解决方案中看到刚才添加的引用加密
4.引用名空间:using System.Web.Security;orm
Click事件中的代码以下:blog
还有一种方法:事件
引用
using System.Security.Cryptography;
using System.Text;md5
具体代码以下(写在按钮的Click事件里):
byte[] result = Encoding.Default.GetBytes(this.tbPass.Text.Trim()); //tbPass为输入密码的文本框
MD5 md5 = new MD5CryptoServiceProvider();
byte[] output = md5.ComputeHash(result);
this.tbMd5pass.Text = BitConverter.ToString(output).Replace("-",""); //tbMd5pass为输出加密文本的文本框it