private void buttonCancel_Click(object sender, EventArgs e)
        {
            string protect = Crypt.Decrypt(_protect.protect, userName + mac, mac + userName, "SHA1", 2,
                                           "32CRYPTODATA0117", 256);
            string key = Crypt.Decrypt(_key.data, userName, mac, "SHA1", 2,
                                       "32CRYPTODATA0117", 256);

            try
            {
                if (protect == key)
                {
                    FormHome home = new FormHome();
                    home.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("There was a problem with the protection system. Data can not be decrypted!", "Protect", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Application.Exit();
                }
            }
            catch
            {
                MessageBox.Show("There was a problem with the protection system. Data can not be decrypted!", "Protect", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Application.Exit();
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string key = Crypt.Decrypt(_key.data, userName, mac, "SHA1", 2,
                                       "32CRYPTODATA0117", 256);

            if (TextBoxPass.Text != "")
            {
                if (TextBoxPass.Text == key)
                {
                    _protect.protect = Crypt.Encrypt(this.TextBoxPass.Text, userName + mac, mac + userName, "SHA1", 2,
                                                     "32CRYPTODATA0117", 256);
                    _protect.Save();
                    FormHome home = new FormHome();
                    home.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Incorrect password!", "Ooops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("You did not enter anything!", "Ooops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }