示例#1
0
 public Feistel(string key1, string key2, Language language, ToPDF pdf)
 {
     this.key1     = key1;
     this.key2     = key2;
     this.language = language;
     this.pdf      = pdf;
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            pdf = new ToPDF();
            string key1 = GetKey1().ToLower(),
                   key2 = GetKey2().ToLower();

            if (key1 == "" || key2 == "")
            {
                MessageBox.Show("Ключи не могут быть пустыми!");
                return;
            }
            int    blockSize = (int)numericUpDown_BlockSize.Value;
            string text      = AddSpaces(blockSize).ToLower();

            string[] textarr = text.Split('\n');
            Feistel  feistel = new Feistel(GetKey1(), GetKey2(), Language.Russian, pdf);

            richTextBox_Output.Text = String.Empty;
            if (radioButton_Coder.Checked)
            {
                for (int i = 0; i < textarr.Length; i++)
                {
                    for (int j = 0; j < textarr[i].Length; j += blockSize)
                    {
                        richTextBox_Output.Text += feistel.Coder(textarr[i].Substring(j, blockSize));
                    }
                    richTextBox_Output.Text += "\n";
                }
            }
            else
            {
                for (int i = 0; i < textarr.Length; i++)
                {
                    for (int j = 0; j < textarr[i].Length; j += blockSize)
                    {
                        richTextBox_Output.Text += feistel.Decoder(textarr[i].Substring(j, blockSize));
                    }
                    richTextBox_Output.Text += "\n";
                }
            }
            pdf.OutToPDFFile();
        }