Exemplo n.º 1
0
        private void Encrypt_Click(object sender, EventArgs e)
        {
            obj = new Hill_cipher();
            int dim = Convert.ToInt32(textBox4.Text);

            int[,] key = new int[dim, dim];
            char[]     delimiterChars = { ' ' };
            string[]   words          = KeytextBox.Text.Split(delimiterChars);
            List <int> layersList     = new List <int>();

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i] != "")
                {
                    layersList.Add(Convert.ToInt32(words[i]));
                }
            }

            layers = new int[dim, dim];
            int cnt = 0;

            for (int i = 0; i < dim; i++)
            {
                for (int j = 0; j < dim; j++)
                {
                    layers[i, j] = layersList[cnt++];
                }
            }
            EncResultTextBox.Text = obj.encrypt(PlaintextBox.Text, layers);
        }
        private void Encrypt_Click(object sender, EventArgs e)
        {
            obj = new Hill_cipher();
            int dim = Convert.ToInt32(textBox4.Text);
            int[,] key = new int[dim, dim];
            char[] delimiterChars = { ' ' };
            string[] words = KeytextBox.Text.Split(delimiterChars);
            List<int> layersList = new List<int>();
            for (int i = 0; i < words.Length; i++)
            {
                if (words[i] != "")
                    layersList.Add(Convert.ToInt32(words[i]));
            }

            layers = new int[dim, dim];
            int cnt = 0;
            for (int i = 0; i < dim; i++)
            {
                for (int j = 0; j < dim; j++)
                {
                    layers[i, j] = layersList[cnt++];
                }
            }
            EncResultTextBox.Text = obj.encrypt(PlaintextBox.Text, layers);
        }