C#之四十 Winform MD5加密

标签: c#stringwinformnamespace
416人阅读 评论(0) 收藏 举报
分类:
using System;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Web.Security;
using System.Web;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static string MD5(string password)
        {
            MD5CryptoServiceProvider md5;
            md5 = new MD5CryptoServiceProvider();
            return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string t1 = textBox1.Text;
            string tm = FormsAuthentication.HashPasswordForStoringInConfigFile(t1, "MD5");
            textBox2.Text = tm;
            textBox3.Text = MD5(t1).Replace("-","");
        }
    }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场