Ejemplo n.º 1
0
        private void BtnEncrypt_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text,
                   password = txtPassword.Text;

            if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show("Type both fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                ToggleControls();

                var encryptDecrypt = _service.EncryptAndDecrypt(userName, password);
                txtAES.Text = encryptDecrypt.EncryptedUserName;
                txtRSA.Text = encryptDecrypt.EncryptedPassword;

                ToggleControls();
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                ExceptionHandlerHelper.ExceptionHandler(ex);
            }
        }