Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (Russian.Checked)
            {
                Rus = true;
            }
            if (English.Checked)
            {
                Eng = true;
            }

            //CryptoAlg Alg = 0;


            Crypto crypting = new Crypto(
                OriginText,
                KeyText,
                (int)tabDiag.Value, Rus, Eng);

            MDPM MonoDigraph = new MDPM(
                Origin,
                Key,
                Rus, Eng);

            Book book = new Book(
                Origin,
                Key);


            if (Alg == CryptoAlg.FibonaccyGamma)
            {
                bool FibEnum = cbFibonaccyEnum.Checked;
                bool FibRec  = cbFibonaccyRec.Checked;
                Result        = crypting.FibonaccyGamm(FibEnum, FibRec);
                ResultSpace   = crypting.Spaces();
                tbResult.Text = ResultSpace;
                tbGamma.Text  = crypting.FibonaccyKey();
            }

            else if (Alg == CryptoAlg.MD)
            {
                Result        = MonoDigraph.MD();
                ResultSpace   = MonoDigraph.Spaces();
                tbResult.Text = ResultSpace;
            }
            else if (Alg == CryptoAlg.Lattice)
            {
                Result        = book.Lattice(Origin, Key);
                tbResult.Text = Result;
            }
            else
            {
                int Shift = (int)nmCesarShift.Value;

                if (Alg == CryptoAlg.Cesar | Alg == CryptoAlg.Viganer)
                {
                    Result        = crypting.Code(Alg, Shift);
                    ResultSpace   = crypting.Spaces();
                    tbResult.Text = ResultSpace;
                }

                if (Alg == CryptoAlg.Viganer)
                {
                    Result        = crypting.Code(Alg, Shift);
                    ResultSpace   = crypting.Spaces();
                    tbResult.Text = ResultSpace;
                }


                else if (Alg == CryptoAlg.ExchangeTables)
                {
                    Result        = crypting.ExchangeTables();
                    ResultSpace   = crypting.Spaces();
                    tbResult.Text = ResultSpace;
                }

                else
                {
                    return;
                }
            }
            tabControl1.SelectedTab = tabPage11;
        }
Пример #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            List <CryptoAlg> Methods = new List <CryptoAlg>();

            foreach (ComboBox item in flowLayoutPanel1.Controls)
            {
                Methods.Add((CryptoAlg)item.SelectedIndex);
            }

            int Shift = (int)nmCesarShift.Value;

            this.Diagonal = (int)tabDiag.Value;

            OriginText = tbText.Text;
            KeyText    = tbGamma.Text;

            if (Russian.Checked)
            {
                Rus = true;
            }
            if (English.Checked)
            {
                Eng = true;
            }

            foreach (CryptoAlg item in Methods)
            {
                switch (item)
                {
                case CryptoAlg.Cesar:
                {
                    Crypto crypting = new Crypto(
                        OriginText,
                        KeyText,
                        Diagonal, Rus, Eng);
                    Alg = CryptoAlg.Cesar;

                    Result     = crypting.Code(Alg, Shift);
                    OriginText = Result;
                    break;
                }

                case CryptoAlg.Viganer:
                {
                    CheckLong CheckViganer = new CheckLong(
                        Origin,
                        KeyText);

                    Alg    = CryptoAlg.Viganer;
                    Origin = tbText.Text;

                    KeyText = CheckViganer.Check(OriginText, KeyText);
                    Crypto crypting = new Crypto(
                        OriginText,
                        KeyText,
                        Diagonal, Rus, Eng);

                    Result       = crypting.Code(Alg, Shift);
                    tbGamma.Text = KeyText;
                    OriginText   = Result;
                    break;
                }

                case CryptoAlg.ExchangeTables:
                {
                    Crypto crypting = new Crypto(
                        OriginText,
                        KeyText,
                        Diagonal, Rus, Eng);
                    Alg = CryptoAlg.ExchangeTables;


                    Diagonal   = (int)tabDiag.Value;
                    Result     = crypting.ExchangeTables();
                    OriginText = Result;
                    break;
                }

                case CryptoAlg.FibonaccyGamma:
                {
                    Crypto crypting = new Crypto(
                        OriginText,
                        KeyText,
                        Diagonal, Rus, Eng);
                    int[] A = new int[5];

                    A[0] = (int)numericUpDown2.Value;
                    A[1] = (int)numericUpDown3.Value;
                    A[2] = (int)numericUpDown4.Value;
                    A[3] = (int)numericUpDown5.Value;
                    A[4] = (int)numericUpDown6.Value;
                    Alg  = CryptoAlg.FibonaccyGamma;

                    bool FibEnum = cbFibonaccyEnum.Checked;
                    bool FibRec  = cbFibonaccyRec.Checked;
                    Result = crypting.FibonaccyGamm(FibEnum, FibRec);

                    OriginText = Result;
                    break;
                }

                case CryptoAlg.MD:
                {
                    MDPM MonoDigraph = new MDPM(OriginText, KeyText, Rus, Eng);

                    Alg        = CryptoAlg.MD;
                    Result     = MonoDigraph.MD();
                    OriginText = Result;
                    break;
                }

                case CryptoAlg.Lattice:
                {
                    Book book = new Book(
                        OriginText,
                        KeyText);
                    Alg = CryptoAlg.Lattice;

                    Result     = book.Lattice(OriginText, Key);
                    OriginText = Result;
                    break;
                }

                default:
                    break;
                }
                tbResult.Text = Result;
            }
        }