コード例 #1
0
ファイル: Form1.cs プロジェクト: RomanShuruiev/Crypto
        private void viganerToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            CheckLong CheckViganer = new CheckLong(
                Origin,
                Key);

            Alg          = CryptoAlg.Viganer;
            Origin       = tbText.Text;
            OriginText   = tbText.Text;
            Key          = tbGamma.Text;
            KeyText      = CheckViganer.Check(Origin, Key);
            tbGamma.Text = KeyText;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: RomanShuruiev/Crypto
        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;
            }
        }