public double encrypt(int p, int q, int e, int m) { double mul = 1; double c = 0; int d; int n = p * q; int q_n = (p - 1) * (q - 1); mul_inverse mul_inv = new mul_inverse(); d = mul_inv.mulinverse(e, q_n); string y = e.ToString(); y = Convert.ToString(Convert.ToInt32(y, 10), 2); int K = y.Count(); for (int i = 0; i < K; i++) { c *= 2; mul = (mul * mul) % n; if (y[i] == '1') { c = c + 1; mul = (mul * m) % n; } } return(mul); }
private void button1_Click(object sender, EventArgs e) { int m = Convert.ToInt32(textBox1.Text); int n = Convert.ToInt32(textBox2.Text); int mulinverse1 = 0; mul_inverse M = new mul_inverse(); int mulinverse = M.mulinverse(m, n); textBox3.Text = Convert.ToString(mulinverse); if (mulinverse < 0) { mulinverse1 = mulinverse + 26;////// bgm3 26 3lashan ageb el modules////// } else { mulinverse1 = mulinverse % 26; } textBox4.Text = Convert.ToString(mulinverse1); }