Beispiel #1
0
        private void Decrypt_Button_Click(object sender, EventArgs e)
        {
            var    localLink     = "F:/SAUGUMO TEST CHAMBER 2/encrypted.txt";
            string encryptedText = File.ReadAllText(localLink);

            var localLink2 = "F:/SAUGUMO TEST CHAMBER 2/public_key.txt";

            string keys = File.ReadAllText(localLink2);

            int[]         arr     = keys.Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
            RSAEncryption decrypt = new RSAEncryption();

            richTextBox4.Text = decrypt.RsaTextDecryption(arr[0], arr[1], encryptedText);


            //MessageBox.Show("vsio");
        }
Beispiel #2
0
        private void EncryptButton_Click(object sender, EventArgs e)
        {
            if (PrimeNumberCheck(int.Parse(textBox1.Text)) && PrimeNumberCheck(int.Parse(textBox2.Text)))
            {
                RSAEncryption encrypt = new RSAEncryption();
                byte[]        b;
                b = encrypt.RsaTextEncryption(int.Parse(textBox1.Text), int.Parse(textBox2.Text), richTextBox1.Text);
                richTextBox2.Text = Convert.ToBase64String(b);
                var localLink = "F:/SAUGUMO TEST CHAMBER 2/encrypted.txt";
                File.WriteAllText(localLink, Convert.ToBase64String(b));
                var    localLink2 = "F:/SAUGUMO TEST CHAMBER 2/public_key.txt";
                string pubkey     = $"{RSAEncryption.publicKey} {RSAEncryption.n}";
                File.WriteAllText(localLink2, pubkey);

                // byte[] test1 = Convert.FromBase64String(richTextBox2.Text);*/
            }
        }