Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string cresult, newkey = "";
            string oldpass = textBox1.Text;
            string newpass = textBox2.Text;

            myclass = new MyClass();

            cresult = myclass.FileMyOpen();
            if (myclass.ComparePass(oldpass, oldkey))
            {
                newkey = myclass.SaveInFile(newpass);
                ChangeButton chmain = new ChangeButton(newkey);
                chmain.Show();
                this.Hide();
            }
            else
            {
                one--;
                MessageBox.Show(String.Format("Неправильный пароль или ключ!\nОсталось попыток: {0}", one));
                if (one == 0)
                {
                    Application.Exit();
                }
            }

            textBox1.Text = "";
            textBox2.Text = "";
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string     s    = "";
            WriteParol main = this.Owner as WriteParol;

            myclass = new MyClass();
            if (main != null)
            {
                s = main.textBox1.Text;             //переменной s присваиваем значение textBox1(пароль)
            }
            string KeyF2    = textBox1.Text;        //введенный ключ
            string password = myclass.FileMyOpen(); //зашифрованный пароль из файла

            if (myclass.ComparePass(s, KeyF2))
            {
                KeyF2 = myclass.SaveInFile(s);
                ChangeButton key2 = new ChangeButton(KeyF2);
                key2.Show();
                this.Hide();
            }
            else if (main != null)
            {
                main.a--;
                MessageBox.Show(String.Format("Неправильный пароль или ключ!\nОсталось попыток: {0}", main.a));
                if (main.a == 0)
                {
                    Application.Exit();
                }
                main.Show();
                main.textBox1.Text = "";
            }
            this.Hide();
        }
        public void button1_Click(object sender, EventArgs e)
        {
            string password = textBox1.Text;
            //string FKey = "";
            MyClass class1 = new MyClass();

            if (File.Exists("password.txt"))
            {
                MyKey f = new MyKey();
                f.Owner = this;
                this.Hide();
                f.Show();
            }
            else
            {
                FileStream fs = new FileStream("password.txt", FileMode.Create, FileAccess.Write);
                fs.Close();
                //FKey = class1.SaveInFile(password);
                ChangeButton fkey = new ChangeButton(class1.SaveInFile(password));
                this.Hide();
                fkey.Show();
            }
        }