Exemple #1
0
        private void Clear_Click(object sender, EventArgs e)
        {
            HashText.Clear();
            PlainText.Clear();
            CipherText.Clear();

            PlainText.Focus();

            this.Encryption.Enabled = true;
        }
Exemple #2
0
        private void Encryption_Click(object sender, EventArgs e)
        {
            this.CipherText.Clear();
            this.HashText.Clear();
            this.Encryption.Enabled = false;


            if (!String.IsNullOrEmpty(PlainText.Text) && !String.IsNullOrWhiteSpace(PlainText.Text))
            {
                this.Decrypt.Enabled = true;

                UnicodeEncoding code  = new UnicodeEncoding();
                byte[]          datas = code.GetBytes(PlainText.Text);

                using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048))
                {
                    byte[] encry = RSA.RSAEncrypt(datas, rsa.ExportParameters(false), false);


                    for (int i = 0; i < encry.Length; i++)
                    {
                        CipherText.Text += encry[i].ToString("X2");
                    }

                    CipherText.Text += rsa.KeySize.ToString();
                    enc              = RSA.RSADecrypt(encry, rsa.ExportParameters(true), false);



                    string sha = HashSHA256.SHA256Hashing(PlainText.Text);


                    HashText.Text += sha;
                }
            }
            else
            {
                MessageBox.Show("Caixa de texto vazia", "Digite algo para criptografar!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Encryption.Enabled = true;
                this.Decrypt.Enabled    = false;

                PlainText.Focus();
            }
        }
 private void aesjia_Load(object sender, EventArgs e)
 {
     PlainText.Focus();
 }