Криптография: реализация квадрата полибия на C#

void sq_polib() {
        
            int n = 0,m=0,x=0;
            mass = new char[8,4];

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (n < textBox1.Text.Length)
                    {
                        mass[i, j] = textBox1.Text[n];
                        n++;
                    }
                  
                }
               

            }
            int ys=0;
            string alf;

           
            alf = alpha;

            for (int i = 0; i < textBox1.Text.Length; i++)
            {
                ys = alf.IndexOf(textBox1.Text[i]);

                alf = alf.Remove(ys,1);
               
            }
                     
            richTextBox2.Text = alf;
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {

                        for (int k = 0; k < alpha.Length; k++)
                            if (mass[i, j] == alpha[k]) x = 1;

                        if (x == 0)
                        {
                            mass[i, j] = alf[m];
                            m++;
                        }
                        x = 0;
                    }
                }
          label2.Text = "";
            for (int i = 0; i < 8; i++)
                for (int j = 0; j < 4; j++)
                { label2.Text+=mass[i,j];}
            label2.Visible = true;
            int rt = 0;
            for(int k=0;k<richTextBox1.Text.Length;k++){
               
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (richTextBox1.Text[k] == mass[i, j])
                        {
                            rt = 1;
                            if (i != 7)
                                sq_p += mass[i + 1, j];
                            else sq_p += mass[0, j];
                          
                        }

                    }
                }
                if (rt == 0)
                    sq_p += richTextBox1.Text[k];
                rt = 0;
            }
            richTextBox2.Clear();
            richTextBox2.Text = sq_p;
        }

Комментарии

Популярные сообщения