private void button4_Click(object sender, EventArgs e) { listBox3.Items.Clear(); long c1 = long.Parse(C1.Text); long c2 = long.Parse(C2.Text); long m1 = long.Parse(MOD1.Text); long m2 = long.Parse(MOD2.Text); Rovnice.Run(listBox3, c1, m1, c2, m2); }
private void button3_Click(object sender, EventArgs e) { long message = Int32.Parse(m.Text); long qE = Int32.Parse(E.Text); long Q = Int32.Parse(q.Text); long P = Int32.Parse(p.Text); listBox2.Items.Clear(); string lajna = "φ(" + P.ToString() + "∙" + Q.ToString() + ")" + " = "; long Pz = P; long Qz = Q; P = Phi.phi((int)P); Q = Phi.phi((int)Q); long d = P * Q; lajna = lajna + P.ToString() + "∙" + Q.ToString() + " = " + d.ToString(); listBox2.Items.Add(lajna); lajna = d.ToString() + "d" + " ≡ " + "0"; listBox2.Items.Add(lajna); lajna = qE.ToString() + "d" + " ≡ " + "1"; listBox2.Items.Add(lajna); listBox2.Items.Add("-------------------------"); DHRovnice rovnice = Inverze.Run(listBox2, d, qE); listBox2.Items.Add("--------------------------"); long umocneni = rovnice.Prava; lajna = "m ≡" + message + "^" + umocneni + "≡"; long c1 = message % Pz; long m1 = umocneni % Phi.phi((int)Pz); lajna = lajna + c1 + "^" + m1; listBox2.Items.Add(lajna); long finalni1 = Umocnovac.Run(listBox2, c1, m1, Pz); lajna = "m" + " ≡ " + finalni1 + " (mod" + Pz + ")"; listBox2.Items.Add(lajna); long c2 = message % Qz; long m2 = umocneni % Phi.phi((int)Qz); lajna = "m ≡" + message + "^" + umocneni + "≡" + c2 + "^" + m2; listBox2.Items.Add(lajna); long finalni2 = Umocnovac.Run(listBox2, c2, m2, Qz); lajna = "m" + " ≡ " + finalni2 + " (mod" + Qz + ")"; listBox2.Items.Add(lajna); listBox2.Items.Add("-----------------------------"); Rovnice.Run(listBox2, finalni1, Pz, finalni2, Qz); }
private void button2_Click(object sender, EventArgs e) { listBox2.Items.Clear(); long message = Int32.Parse(m.Text); long qE = Int32.Parse(E.Text); long Q = Int32.Parse(q.Text); long P = Int32.Parse(p.Text); StringBuilder builder = new StringBuilder(); builder.Append("c ≡ "); builder.Append(message.ToString()); builder.Append(" ^ "); builder.Append(qE.ToString()); long c1 = message % P; long reducedE = (long)(qE % MathEngine.Phi.phi((int)P)); builder.Append(" ≡ "); builder.Append(c1); builder.Append(" ^ "); builder.Append(reducedE); listBox2.Items.Add(builder.ToString()); builder.Clear(); c1 = Umocnovac.Run(listBox2, c1, reducedE, P); builder.Append(" ≡ "); c1 = c1 % P; builder.Append(c1); builder.Append(" (mod" + P.ToString() + ")"); listBox2.Items.Add(builder.ToString()); builder.Clear(); /////////////////////////// builder.Append("c ≡ "); builder.Append(message.ToString()); builder.Append(" ^ "); builder.Append(qE.ToString()); long c2 = message % Q; long reducedE2 = qE % MathEngine.Phi.phi((int)Q); builder.Append(" ≡ "); builder.Append(c2); builder.Append(" ^ "); builder.Append(reducedE2); listBox2.Items.Add(builder.ToString()); builder.Clear(); c2 = Umocnovac.Run(listBox2, c2, reducedE2, Q); builder.Append(" ≡ "); c2 = c2 % Q; builder.Append(c2); builder.Append(" (mod" + Q.ToString()); listBox2.Items.Add(builder.ToString() + ")"); builder.Clear(); listBox2.Items.Add("------------------------------------------------------"); DHRovnice rovnice = Rovnice.Run(listBox2, c1, P, c2, Q); }