Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox2.Clear();
            string keyWord = textBox1.Text;
            int    key     = int.Parse(textBox2.Text);


            Caesar.createNewAlpha(keyWord, key);
            open  = "";
            close = "";
            close = Caesar.encrypt(richTextBox1.Text);
            richTextBox2.AppendText("Зашифрованное: " + close + "\n");
            richTextBox2.AppendText("");
            try
            {
                richTextBox2.AppendText("1. " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(0).Key.ToString() + " " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(0).Count().ToString() + "\n");
                richTextBox2.AppendText("2. " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(1).Key.ToString() + " " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(1).Count().ToString() + "\n");
                richTextBox2.AppendText("3. " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(2).Key.ToString() + " " + close.GroupBy(c => c).OrderByDescending(g => g.Count()).ElementAt(2).Count().ToString() + "\n");
            }
            catch
            {
                MessageBox.Show("ENTER AT LEAST 3 SYMBOLS");
            }

            File.WriteAllText("message.txt", close);
            textBox3.Clear();
            for (int i = 0; i < newAlpha.Length; i++)
            {
                textBox3.Text += newAlpha[i];
            }
        }
Esempio n. 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     richTextBox2.Clear();
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string close = File.ReadAllText(openFileDialog1.FileName);
         close = Caesar.decrypt(close);
         richTextBox2.AppendText("Рассшифрованное: " + close + "\n");
     }
 }