private void f4_button_SetCb_Click(object sender, EventArgs e) { f4_textCb.Text = new string(f4_textCb.Text.Where(t => char.IsDigit(t)).ToArray()); if (f4_textCb.TextLength > 0) { BigInteger P = BigInteger.Parse(f4_textP.Text); BigInteger Cb = BigInteger.Parse(f4_textCb.Text); if ((NumberTheory.GCD(Cb, P - 1, out BigInteger x, out BigInteger y) == 1)) { f4_textDb.Text = Convert.ToString(NumberTheory.Foo(Cb, P - 1)); f4_textCb.ReadOnly = true; f4_button_GetRandomCb.Enabled = false; f4_button_SetCb.Enabled = false; f4_button_ChangeCb.Enabled = true; } } }
private void f9_button_SetSecretKey_Click(object sender, EventArgs e) { f9_textSecretKey.Text = new string(f9_textSecretKey.Text.Where(t => char.IsDigit(t)).ToArray()); BigInteger SecretKey; BigInteger P = BigInteger.Parse(f9_textP.Text); BigInteger Q = BigInteger.Parse(f9_textQ.Text); BigInteger N = BigInteger.Parse(f9_textN.Text); BigInteger fi = (P - 1) * (Q - 1); // Функция Эйлера от N if (f9_textSecretKey.TextLength > 0) { SecretKey = BigInteger.Parse(f9_textSecretKey.Text); SecretKey = SecretKey % N; if (SecretKey > 1 && NumberTheory.GCD(SecretKey, fi, out BigInteger x, out BigInteger y) == 1) { f9_textOpenKey.Text = Convert.ToString(NumberTheory.Foo(SecretKey, fi)); f9_button_SetSecretKey.Enabled = false; f9_button_GetRandomSecret.Enabled = false; f9_button_ClearSecretKey.Enabled = true; f9_buttonSign.Enabled = true; } } }