private void Button_Click_6(object sender, RoutedEventArgs e) { if ((RSAD.Text.Length > 0) && (RSAN.Text.Length > 0)) { long d = Convert.ToInt64(RSAD.Text); long n = Convert.ToInt64(RSAN.Text); List <string> input = new List <string>(); var input2 = RSAInput2.Text.Split(); foreach (var Item in input2) { if (Item != "") { input.Add(Item); } } string result = RSAChiper.RSA_Dedoce(input, d, n); RSAOutput2.Text = result; } else { MessageBox.Show("Введите секретный ключ!"); } }
private void Button_Click_5(object sender, RoutedEventArgs e) { if ((RSAP.Text.Length > 0) && (RSAQ.Text.Length > 0)) { long p = Convert.ToInt64(RSAP.Text); long q = Convert.ToInt64(RSAQ.Text); if (RSAChiper.IsTheNumberSimple(p) && RSAChiper.IsTheNumberSimple(q)) { string s = RSAInput.Text; s = s.ToUpper(); long n = p * q; long m = (p - 1) * (q - 1); long d = RSAChiper.Calculate_d(m); long e_ = RSAChiper.Calculate_e(d, m); var result = RSAChiper.RSA_Endoce(s, e_, n); foreach (var Item in result) { RSAOutput.Text += Item + Environment.NewLine; } RSAD.Text = d.ToString(); RSAN.Text = n.ToString(); RSAInput2.Text = RSAOutput.Text; RSAP2.Text = RSAP.Text; RSAQ2.Text = RSAQ.Text; RSAD2.Text = RSAD.Text; RSAN2.Text = RSAN.Text; } else { MessageBox.Show("p или q - не простые числа!"); } } else { MessageBox.Show("Введите p и q!"); } }