Exemple #1
0
        private void btn_encrypt_Click(object sender, EventArgs e)
        {
            string plainText = tb_plainText.Text.Trim();

            if (plainText != "")
            {
                writeLog("Converting " + plainText + " to byte...");
                byte[] data      = Encoding.UTF8.GetBytes(plainText);
                byte[] encrypted = rsa.Encrypt(data);
                writeLog("Using the public key to encrypt your text");
                tb_cipherText.Text = Convert.ToBase64String(encrypted);
                writeLog("-------------- The encryption is compeleted! --------------");
            }
            else
            {
                AlertError("Nothing to encrypt.");
            }
        }