private void EncButton_Click(object sender, EventArgs e) { if (InputRichTextBox.Text == "") { MessageBox.Show("Введите данные для шифрования", "Ошибка"); } else if (PKeyTB.Text == "" || GKeyTB.Text == "" || XKeyTB.Text == "") { MessageBox.Show("Не все ключи введены", "Ошибка"); } else if (int.Parse(GKeyTB.Text) >= int.Parse(PKeyTB.Text) || int.Parse(XKeyTB.Text) >= int.Parse(PKeyTB.Text) || !Prime.Contains(int.Parse(PKeyTB.Text))) { MessageBox.Show("Введены некорретные ключи", "Ошибка"); } else { TimeStart(); int p = Convert.ToInt32(PKeyTB.Text); int g = Convert.ToInt32(GKeyTB.Text); int x = Convert.ToInt32(XKeyTB.Text); Algorithm_El_Gamal.AlgorithmEG eg = new Algorithm_El_Gamal.AlgorithmEG(); int y = eg.PublicKey(p, g, x); YKeyTB.Text = y.ToString(); OutputRichTextBox.Text = eg.Crypt(p, g, x, y, InputRichTextBox.Text); TimeStop(); } }
private void DecButton_Click(object sender, EventArgs e) { if (OutputRichTextBox.Text == "") { MessageBox.Show("Введите данные для расшифрования", "Ошибка"); } else if (PKeyTB.Text == "" || GKeyTB.Text == "" || XKeyTB.Text == "") { MessageBox.Show("Не все ключи введены", "Ошибка"); } else { TimeStart(); int p = Convert.ToInt32(PKeyTB.Text); int g = Convert.ToInt32(GKeyTB.Text); int x = Convert.ToInt32(XKeyTB.Text); Algorithm_El_Gamal.AlgorithmEG eg = new Algorithm_El_Gamal.AlgorithmEG(); int y = eg.PublicKey(p, g, x); YKeyTB.Text = y.ToString(); OutputRichTextBox.Text = eg.Decrypt(p, x, OutputRichTextBox.Text); TimeStop(); } }