Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txt_UserName.Text == "" || txt_Password.Text == "")
            {
                MessageBox.Show("Please provide UserName and Password");
                return;
            }
            try
            {
                CheckPassword CP = new CheckPassword();
                CP.txt_Password = txt_Password.Text;
                CP.txt_UserName = txt_UserName.Text;

                CP.CheckIfLoginIsAccepted();

                if (CP.AccessAllowed)
                {
                    MessageBox.Show("Login Successful!");
                    this.Hide();
                    MainUI fm = new MainUI();
                    fm.Show();
                }
                else
                {
                    MessageBox.Show("Login Failed!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public void CanSaltHashDehashDesalt()
        {
            CU = new SaltUserPassword();
            CP = new CheckPassword();

            string SaltedAndHashedPassword = CU.PasswordSaltHash("1");

            CP.txt_Password = SaltedAndHashedPassword;
            CP.txt_UserName = "******";
            try
            {
                CP.CheckIfLoginIsAccepted();
            }
            catch (UnauthorizedAccessException)
            {
            }


            Assert.IsTrue(CP.AccessAllowed);
        }