void background_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the RSA public key that we will use
            string cert = http.Post(address, "getkey=y");

            rsa.LoadCertificateFromString(cert);

            // Generate the AES keys, encrypt them with the RSA public key, then send them to the PHP script.
            aes.GenerateRandomKeys();
            string key    = Utility.ToUrlSafeBase64(rsa.Encrypt(aes.EncryptionKey));
            string iv     = Utility.ToUrlSafeBase64(rsa.Encrypt(aes.EncryptionIV));
            string result = http.Post(address, "key=" + key + "&iv=" + iv);

            // If the PHP script sends this message back, then the connection is now good.
            connected = (result == "AES OK");
        }
Esempio n. 2
0
        private void btnSendTest2_Click(object sender, EventArgs e)
        {
            btnSendTest2.Enabled = false;

            PostPackageBuilder postVars = new PostPackageBuilder();
            string             code     = rsa.Encrypt(txtMessage2.Text);

            postVars.AddVariable("code", code);

            txtEncrypted2.Text = code;

            if (!http2.IsBusy)
            {
                http2.Post(txtAddress2.Text, postVars);
            }
        }