Пример #1
0
 private void BtnPwd_Click(object sender, EventArgs e)
 {
     if (txtBoxOriginalPwd.TextLength > 0 && txtBoxNewPwd1.TextLength > 0 && txtBoxNewPwd2.TextLength > 0)
     {
         MD5    md5      = new MD5CryptoServiceProvider();
         byte[] output   = md5.ComputeHash(Encoding.Default.GetBytes(txtBoxOriginalPwd.Text.Trim()));
         string strValue = BitConverter.ToString(output).Replace("-", "");
         if (strValue == m_db.GetPassWord())
         {
             if (txtBoxNewPwd1.Text != txtBoxNewPwd2.Text)
             {
                 MessageBox.Show("两次输入的新密码不一致!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 output   = md5.ComputeHash(Encoding.Default.GetBytes(txtBoxNewPwd1.Text.Trim()));
                 strValue = BitConverter.ToString(output).Replace("-", "");
                 if (m_db.SetPassWord(strValue) == 1)
                 {
                     MessageBox.Show("修改管理员密码成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("修改管理员密码失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             MessageBox.Show("原密码不正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         md5.Dispose();
     }
 }
Пример #2
0
        private void BtnOK_Click(object sender, EventArgs e)
        {
            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] output   = md5.ComputeHash(Encoding.Default.GetBytes(this.txtBoxPassWord.Text.Trim()));
            string strValue = BitConverter.ToString(output).Replace("-", "");

            if (strValue == m_db.GetPassWord())
            {
                this.DialogResult = DialogResult.Yes;
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
            md5.Dispose();
            this.Close();
        }