private void button1_Click(object sender, EventArgs e) { textBox1.Text = null; if (textBoxKeyWord.Text.Length > 0) { string s = ""; StreamReader sr = new StreamReader("Ciph3\\in.txt"); StreamWriter sw = new StreamWriter("Ciph3\\out.txt"); while (!sr.EndOfStream) { s += sr.ReadLine(); } string stmp = ""; foreach (char symbol in s) { if (Regex.IsMatch(Convert.ToString(symbol), @"[\u0400-\u04FF]")) { stmp += symbol; } } s = stmp; string cipherout = new Vizhener().Encode(s, textBoxKeyWord.Text); sw.WriteLine(cipherout); textBox1.Text += cipherout; sr.Close(); sw.Close(); } else { MessageBox.Show("Введите ключевое слово!"); } }
private void button2_Click(object sender, EventArgs e) { textBox1.Text = null; if (textBoxKeyWord.Text.Length > 0) { string s; StreamReader sr = new StreamReader("Ciph3\\out.txt"); StreamWriter sw = new StreamWriter("Ciph3\\outAfterDecode.txt"); while (!sr.EndOfStream) { s = sr.ReadLine(); string cipherout = new Vizhener().Decode(s, textBoxKeyWord.Text); sw.WriteLine(cipherout); textBox1.Text += cipherout; } sr.Close(); sw.Close(); } else { MessageBox.Show("Введите ключевое слово!"); } }