private void btn_changepassword_Click(object sender, EventArgs e)
        {
            if (txt_newpassword.Text == "")
            {
                txt_newpassword.Focus();
                errorProvider1.SetError(txt_newpassword, "Please enter the new Password");
            }
            else if (txt_confirmnewpassword.Text == "")
            {
                txt_confirmnewpassword.Focus();
                errorProvider2.SetError(txt_confirmnewpassword, "Please confirm the new Password");
            }
            else if (txt_newpassword.Text == txt_confirmnewpassword.Text)
            {
                byte[] data = UTF8Encoding.UTF8.GetBytes(txt_confirmnewpassword.Text);
                using (MD5CryptoServiceProvider mdS = new MD5CryptoServiceProvider())
                {
                    byte[] keys = mdS.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
                    using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider()
                    {
                        Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7
                    })
                    {
                        ICryptoTransform transform = tripDes.CreateEncryptor();
                        byte[]           results   = transform.TransformFinalBlock(data, 0, data.Length);
                        lbl_encrypttext.Text = Convert.ToBase64String(results, 0, results.Length);
                    }
                }

                int uuid;
                int.TryParse(lbl_userid.Text, out uuid);

                tbl_user_detailsTableAdapter1.UpdateQueryForChangePassword(lbl_encrypttext.Text, uuid);

                MessageBox.Show("Password has been successfully changed!");

                frm_changepassword frm = new frm_changepassword();
                frm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Password has not been changed successfully!");
            }
        }
Example #2
0
        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_changepassword frm = new frm_changepassword();

            frm.Show();
        }