Пример #1
0
        public void Menu_Load(object sender, EventArgs e)
        {
            Shifr.raskl();
            Shifr.read();

            for (int i = 0; i < Config.names.Length; i++)
            {
                if (Config.names[i] == button_settings.Name)
                {
                    button_settings.Text = Config.names[i + 1];
                }
                if (Config.names[i] == Create.Name)
                {
                    Create.Text = Config.names[i + 1];
                }
                if (Config.names[i] == Get.Name)
                {
                    Get.Text = Config.names[i + 1];
                }
                if (Config.names[i] == Help.Name)
                {
                    Help.Text = Config.names[i + 1];
                }
                if (Config.names[i] == "error")
                {
                    Config.error = Config.names[i + 1];
                }
            }
        }
Пример #2
0
        private void button_edit_Click(object sender, EventArgs e)
        {
            Create.check_length(textBox2.Text, comboBox1.Text);
            if (Config.you_can)
            {
                File.WriteAllText("pas.txt", "");
                StreamWriter f = new StreamWriter("pas.txt", true);
                for (int i = 0; i < Config.vs.Length; i++)
                {
                    if (comboBox1.Text == Config.vs[i])
                    {
                        Shifr.doit(textBox2.Text, Config.alf);

                        f.WriteLine(Config.vs[i] + ":" + Config.vs[i + 1] + "|" + Convert.ToString(Config.dif) + "+" + Config.textshifr);
                        MessageBox.Show("Ok");
                        Config.textshifr = "";
                    }
                    else
                    {
                        if (i % 3 == 0)
                        {
                            f.WriteLine(Config.vs[i] + ":" + Config.vs[i + 1] + "|" + Config.vs[i + 2]);
                        }
                    }
                }
                f.Close();
                label1.Text   = textBox2.Text;
                textBox2.Text = "";
            }
            Config.you_can = true;

            Editing_Load(sender, e);
        }
Пример #3
0
        public static void Overwhite()
        {
            String pas = File.ReadAllText("pas.txt");

            Config.vs = pas.Split(new char[] { ':', '\r', '\n', '|', }, StringSplitOptions.RemoveEmptyEntries);
            List <string> l = new List <string>();

            for (int i = 1; i <= Config.vs.Length; i++)
            {
                if (i % 3 == 0)
                {
                    Shifr.translate(Config.vs[i - 1]);
                    l.Add(Config.textdeshifr);
                    Config.textdeshifr = "";
                }
                else
                {
                    l.Add(Config.vs[i - 1]);
                }
            }
            File.WriteAllText("pas.txt", "");
            Shifr.raskl();
            StreamWriter f = new StreamWriter("pas.txt", true);

            for (int i = 1; i <= l.Count; i++)
            {
                if (i % 3 == 0)
                {
                    Shifr.doit(l[i - 1], Config.alf);
                    f.Write(l[i - 3] + ":" + l[i - 2] + ":" + Convert.ToString(Config.dif) + "+" + Config.textshifr + Environment.NewLine);
                    Config.textshifr = "";
                }
            }
            f.Close();
        }
Пример #4
0
 private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
 {
     for (int i = 0; i < Config.vs.Length; i++)
     {
         if (Config.vs[i] == comboBox1.Text)
         {
             Shifr.translate(Config.vs[i + 2]);
             label1.Text = Config.textdeshifr;
         }
     }
 }
Пример #5
0
        private void button_add_Click(object sender, EventArgs e)
        {
            char [] elem = textBox1.Text.ToCharArray();
            bool    est  = false;

            for (int i = 0; i < Config.alf.Length; i++)
            {
                for (int u = 0; u < elem.Length; u++)
                {
                    if (elem[u] == Config.alf[i])
                    {
                        est = true;
                        MessageBox.Show(Config.It_is);
                        break;
                    }


                    else if (elem[u] == '+' || elem[u] == '"' || elem[u] == ':' || elem[u] == '|')
                    {
                        if (Config.rus_lang)
                        {
                            MessageBox.Show("Это служебный символ");
                        }
                        else
                        {
                            MessageBox.Show("This is a service symbol");
                        }
                        est = true;
                        break;
                    }
                }
            }
            if (!est)
            {
                StreamWriter f = new StreamWriter("Resours\\alfeng.txt", true);
                for (int i = 0; i < elem.Length; i++)
                {
                    f.WriteLine(elem[i]);
                }

                MessageBox.Show("Ok!");
                f.Close();

                Shifr.Overwhite();
                see();
                Shifr.raskl();

                New_element_Load(sender, e);
            }
        }
Пример #6
0
        private void button_change_Click(object sender, EventArgs e)
        {
            if (!Config.rus_lang)
            {
                Config.rus_lang = true;
            }
            else
            {
                Config.rus_lang = false;
            }
            Shifr.read();

            Settings_Load(sender, e);
        }
Пример #7
0
        private void button_save_Click(object sender, EventArgs e)
        {
            check_length(textBox_password.Text, textBox_site.Text);

            if (Config.you_can)
            {
                if (textBox_name.Text == "")
                {
                    textBox_name.Text = "https://null";
                }
                string stroka = textBox_password.Text;

                Shifr.doit(stroka, Config.alf);
                StreamWriter f = new StreamWriter("pas.txt", true);
                string[]     adress;
                if (textBox_name.Text.Contains("https://") || textBox_name.Text.Contains("http://"))
                {
                    adress = textBox_name.Text.Split(new string[] { "https://", "http://" }, StringSplitOptions.RemoveEmptyEntries);
                    f.WriteLine(textBox_site.Text + ":" + adress[0] + "|" + Convert.ToString(Config.dif) + "+" + Config.textshifr);
                }
                else
                {
                    f.WriteLine(textBox_site.Text + ":" + textBox_name.Text + "|" + Convert.ToString(Config.dif) + "+" + Config.textshifr);
                }
                f.Close();
                Config.textshifr = "";
                string message;
                if (Config.rus_lang)
                {
                    message = "Ваш пароль успешно сохранен!";
                }
                else
                {
                    message = "Your password was saved!";
                }
                MessageBox.Show(message);

                textBox_name.Clear();
                textBox_site.Clear();
                textBox_password.Clear();
            }
            Config.you_can = true;

            Create_Load(sender, e);
        }
Пример #8
0
        private void Get_Load(object sender, EventArgs e)
        {
            comboBox_site.Items.Clear();

            Shifr.raskl();
            Shifr.read();
            for (int i = 0; i < Config.names.Length; i++)
            {
                if (Config.names[i] == label_choose.Name)
                {
                    // label_choose.Text = " ";
                    label_choose.Text = Config.names[i + 1];
                }
                if (Config.names[i] == this.Name)
                {
                    this.Text = Config.names[i + 1];
                }
                if (Config.names[i] == label_password.Name)
                {
                    label_password.Text = Config.names[i + 1];
                }
                if (Config.names[i] == button_get.Name)
                {
                    button_get.Text = Config.names[i + 1];
                }
                if (Config.names[i] == label_name.Name)
                {
                    label_name.Text = Config.names[i + 1];
                }
            }


            String pas = File.ReadAllText("pas.txt");

            Config.vs = pas.Split(new char[] { ':', '\r', '\n', '|', }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < Config.vs.Length; i++)
            {
                if (i % 3 == 0)
                {
                    comboBox_site.Items.Add(Config.vs[i]);
                }
            }
        }
Пример #9
0
        private void button_get_Click(object sender, EventArgs e)
        {
            string text = "";

            for (int i = 0; i < Config.vs.Length; i++)
            {
                if (comboBox_site.Text == Config.vs[i])
                {
                    Config.adress = Config.vs[i + 1];
                    text          = Config.vs[i + 2];
                }
            }
            Shifr.translate(text);
            if (Config.adress != "null")
            {
                textBox1.Text = "https://" + Config.adress;
            }
            else
            {
                textBox1.Text = "";
            }
            textBox_password.Text = Config.textdeshifr;
            Config.textdeshifr    = "";
        }
Пример #10
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            bool est = false;

            char[] elem = textBox1.Text.ToCharArray();
            for (int u = 0; u < elem.Length; u++)
            {
                for (int i = 0; i < Config.alf.Length; i++)
                {
                    if (elem[u] == Config.alf[i])
                    {
                        Config.alf[i] = '\n';
                        est           = true;
                    }



                    else if (elem[u] == '+' || elem[u] == '"' || elem[u] == ':' || elem[u] == '|')
                    {
                        if (Config.rus_lang)
                        {
                            MessageBox.Show("Это служебный символ");
                        }
                        else
                        {
                            MessageBox.Show("This is a service symbol");
                        }
                        est = false;
                        break;
                    }
                }
                if (est)
                {
                    File.WriteAllText("Resours\\alfeng.txt", "");
                    StreamWriter f = new StreamWriter("Resours\\alfeng.txt", true);
                    for (int y = 0; y < Config.alf.Length; y++)
                    {
                        f.WriteLine(Config.alf[y]);
                    }

                    MessageBox.Show("Ok!");
                    f.Close();

                    Shifr.Overwhite();
                    see();
                    Shifr.raskl();

                    New_element_Load(sender, e);
                }
                else
                {
                    if (Config.rus_lang)
                    {
                        MessageBox.Show("Такого символа нет");
                    }
                    else
                    {
                        MessageBox.Show("It is not had this symbol");
                    }
                }
            }
        }
Пример #11
0
        public static void check_length(string stroka, string acc)
        {
            if (acc == "")
            {
                if (Config.rus_lang)
                {
                    MessageBox.Show("Введите название аккаунта");
                }
                else
                {
                    MessageBox.Show("Write name of your account");
                }
                Config.you_can = false;
            }

            else if (stroka == "")
            {
                if (Config.rus_lang)
                {
                    MessageBox.Show("Введите пароль");
                }
                else
                {
                    MessageBox.Show("Write your password");
                }
                Config.you_can = false;
            }
            if (stroka.Length >= 25)
            {
                if (Config.rus_lang)
                {
                    MessageBox.Show("Пароль должен содержать менее 25 символов");
                }
                else
                {
                    MessageBox.Show("Password should be less then 25 symbols");
                }
                Config.you_can = false;
            }
            if (stroka.Contains(Convert.ToString('+')) || stroka.Contains(Convert.ToString(':')) || stroka.Contains(Convert.ToString('"')) || stroka.Contains(Convert.ToString('|')))
            {
                if (Config.rus_lang)
                {
                    MessageBox.Show("Пароль не должен содержать символы '+', кавычки, '|' или ':'");
                }
                else
                {
                    MessageBox.Show("Password shouldn't contains '+', quotation marks, '|' or ':'");
                }
                Config.you_can = false;
            }
            Shifr.have_it(stroka, Config.alf);
            if (Config.error_no_symbol)
            {
                Config.error_no_symbol = false;
                Config.you_can         = false;

                if (Config.rus_lang)
                {
                    DialogResult res = MessageBox.Show("Символов " + Config.ot_symb + " нет в алфавите, добавить их?", "Ошибка", MessageBoxButtons.YesNo);
                    if (res == DialogResult.Yes)
                    {
                        New_element form = new New_element(Config.ot_symb);
                        form.Show();
                    }
                }
                else
                {
                    DialogResult res = MessageBox.Show("Alphabet doesn't have " + Config.ot_symb + ". Do you want add this symbols?", "Error", MessageBoxButtons.YesNo);
                    if (res == DialogResult.Yes)
                    {
                        New_element form = new New_element(Config.ot_symb);
                        form.Show();
                    }
                }
            }
        }
Пример #12
0
        private void Help_Load(object sender, EventArgs e)
        {
            if (Config.rus_lang)
            {
                pictureBox4.Image = new Bitmap("Resours\\Mainrus.jpg");
                pictureBox1.Image = new Bitmap("Resours\\Create_rus.jpg");
                pictureBox2.Image = new Bitmap("Resours\\Get_rus.jpg");
                pictureBox3.Image = new Bitmap("Resours\\Editing_rus.jpg");
                pictureBox5.Image = new Bitmap("Resours\\Add_rus.jpg");
            }
            else
            {
                pictureBox4.Image = new Bitmap("Resours\\Maineng.jpg");
                pictureBox1.Image = new Bitmap("Resours\\Create.jpg");
                pictureBox2.Image = new Bitmap("Resours\\Get.jpg");
                pictureBox3.Image = new Bitmap("Resours\\Editing.jpg");
                pictureBox5.Image = new Bitmap("Resours\\Add.jpg");
            }
            Shifr.read();

            for (int i = 0; i < Config.names.Length; i++)
            {
                if (Config.names[i] == textBox_about.Name)
                {
                    textBox_about.Text = Config.names[i + 1];
                }
                if (Config.names[i] == textBox_add.Name)
                {
                    textBox_add.Text = Config.names[i + 1];
                }
                if (Config.names[i] == textBox_ed.Name)
                {
                    textBox_ed.Text = Config.names[i + 1];
                }
                if (Config.names[i] == textBox_create.Name)
                {
                    textBox_create.Text = Config.names[i + 1];
                }
                if (Config.names[i] == textBox_get.Name)
                {
                    textBox_get.Text = Config.names[i + 1];
                }
                if (Config.names[i] == tabControl.TabPages[0].Name)
                {
                    tabControl.TabPages[0].Text = Config.names[i + 1];
                }
                if (Config.names[i] == tabControl.TabPages[1].Name)
                {
                    tabControl.TabPages[1].Text = Config.names[i + 1];
                }
                if (Config.names[i] == tabControl.TabPages[2].Name)
                {
                    tabControl.TabPages[2].Text = Config.names[i + 1];
                }
                if (Config.names[i] == tabControl.TabPages[3].Name)
                {
                    tabControl.TabPages[3].Text = Config.names[i + 1];
                }
                if (Config.names[i] == tabControl.TabPages[4].Name)
                {
                    tabControl.TabPages[4].Text = Config.names[i + 1];
                }
            }
        }