예제 #1
0
 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);
     }
 }
예제 #2
0
        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());
        }
예제 #3
0
        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);
        }