private void button2_Click(object sender, EventArgs e) { try { var provider = new RSACryptoProvider(Int64.Parse(textBox5.Text), Int64.Parse(textBox4.Text), Int64.Parse(textBox3.Text), Int32.Parse(textBox7.Text), Int32.Parse(textBox6.Text)); textBox1.Text = provider.Decrypt(textBox2.Text); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public String Decrypt(String Cyphertext) { var numericalEquivalents = RSACryptoProvider.GetNumericalEquivalents(Cyphertext, this.CypherTextBlockSize); String result = ""; foreach (var n in numericalEquivalents) { var decrypted = Math.Pow(n, this.DecryptionExponent, this.Modulus); result += GetStringEquivalent(decrypted, PlainTextBlockSize); } return(result.ToLower()); }
public String Encrypt(String Plaintext) { var numericalEquivalents = RSACryptoProvider.GetNumericalEquivalents(Plaintext.ToUpper(), this.PlainTextBlockSize); String result = ""; foreach (var n in numericalEquivalents) { var encrypted = Math.Pow(n, EncryptionExponent, Modulus); result += GetStringEquivalent(encrypted, CypherTextBlockSize); } return(result); }