Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strMD5 = "";                                                       //记录加密后的数值
            MD5    _md5   = new MD5CryptoServiceProvider();                           //创建MD5对象

            byte[] data    = System.Text.Encoding.Default.GetBytes(textBox_PWD.Text); //将文本框输入的数据转化为字节
            byte[] md5Data = _md5.ComputeHash(data);                                  //计算data字节数组的哈希值(加密)
            _md5.Clear();                                                             //释放类资源
            foreach (byte a in md5Data)
            {
                if (a < 16)
                {
                    strMD5 += "0" + a.ToString("x");
                }
                else
                {
                    strMD5 += a.ToString("x");
                }
            }

            string userName = textBox_UserName.Text;
            string pwd      = strMD5;

            //校验用户名密码

            if (m_strUser.Equals(userName) && m_strPassword.Equals(pwd))
            {
                this.Hide();
                Mainform form1 = new Mainform();
                form1.Show();
            }
            else
            {
                MessageBox.Show("密码错误!");
                return;
            }
        }
Beispiel #2
0
        private delegate void CrossThreadOperationControl();//跨线程调用控件委托

        public Mainform()
        {
            InitializeComponent();
            form1 = this;
        }