private void btnMaHoa_Click(object sender, EventArgs e1) { try { using (StreamReader sr = new StreamReader(duongdanfile)) { string ketqua = ""; int e = Convert.ToInt32(txte.Text); int N = Convert.ToInt32(txtN.Text); String line = sr.ReadToEnd(); string textnhapvao = line; char[] mangchar = line.ToCharArray(); List <int> mangso = new List <int>(); foreach (char c in mangchar) { mangso.Add(Convert.ToInt32(c)); } foreach (int i in mangso) { int soketquagiaima = GiaiThuat.MaHoaBaoMatRSA(e, N, i); char charduocmahoa = (char)soketquagiaima; ketqua = ketqua + charduocmahoa; } txtKetQua.Text = ketqua; } } catch { MessageBox.Show("Có lỗi xảy ra"); } }
private void btnTestMHBM_Click(object sender, EventArgs e1) { try { int M = Convert.ToInt32(txtTestM.Text); int e = Convert.ToInt32(txte.Text); int N = Convert.ToInt32(txtN.Text); int soketqua = GiaiThuat.MaHoaBaoMatRSA(e, N, M); txtTestResult.Text = soketqua.ToString(); } catch { MessageBox.Show("Có lỗi xảy ra."); } }