Example #1
0
        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!");
            }
        }