示例#1
0
        private void btnMaHoa_Click(object sender, EventArgs e)
        {
            try
            {
                int m;
                if (txtM.Text.Length == 1 && 'a' <= txtM.Text[0] && txtM.Text[0] <= 'z')
                {
                    m = (int)(txtM.Text[0]);
                }
                else
                {
                    m = int.Parse(txtM.Text);
                }
                int p = int.Parse(txtP.Text);
                int q = int.Parse(txtQ.Text);



                if (!IsPrime(p) || !IsPrime(q))
                {
                    MessageBox.Show("P và Q phải là số nguyên tố");
                    return;
                }
                rSA       = new RSAAlgorithm(p, q);
                txtC.Text = rSA.Encrypt(m).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
示例#2
0
 public frmMaHoaVanBan()
 {
     InitializeComponent();
     rSA = new RSAAlgorithm(11, 13);
 }