private void btnDecrypt_Click(object sender, EventArgs e) { switch (criptareToolStripMenuItem.Text) { case "Greek": SimpleInput simpleInput = new SimpleInput(); if (simpleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.GREEK, new object[] { simpleInput.txtKey.Text }); } break; case "Caesar": simpleInput = new SimpleInput(); if (simpleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.CAESAR, new object[] { simpleInput.txtKey.Text }); } break; case "Playfair": simpleInput = new SimpleInput(); if (simpleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.PLAYFAIR, new object[] { simpleInput.txtKey.Text }); } break; case "ADFGVX": DoubleInput doubleInput = new DoubleInput(); if (doubleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ADFGVX, new object[] { doubleInput.txtKey1.Text, doubleInput.txtKey2.Text }); } break; case "Homophonic": txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.HOMOPHONIC, new object[] { }); break; case "Enigma": simpleInput = new SimpleInput(); if (simpleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ENIGMA, new object[] { simpleInput.txtKey.Text }); } break; // TODO: add message for DES case "RSA": MessageBox.Show("In the next dialog, select number of bits for the key."); simpleInput = new SimpleInput(); if (simpleInput.ShowDialog() == DialogResult.OK) { txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.RSA, new object[] { simpleInput.txtKey.Text }); } break; default: MessageBox.Show("Select encryption mode from menu."); break; } }
private void DocumentPush() { // TO DO nothing to push tip if (ActiveCanvas.Document == null) { return; } try { string docPath = ActiveCanvas.Document.FilePath; using (var repo = new Repository(getWorkDir(docPath))) { GH_SettingsServer sserver = new GH_SettingsServer("ggit"); if (repo.Network.Remotes["origin"] == null) { MessageBox.Show("Remote origin is not exist, create a repository remotely, something like github, and paste the url into next window form."); SingleInput inputer = new SingleInput(); inputer.Text = "Remote Url"; inputer.singleLabel.Text = "Remote Url"; inputer.ConfirmEvent += (sender, content) => { repo.Network.Remotes.Add("origin", content); inputer.Close(); }; inputer.ShowDialog(); return; } Remote remote = repo.Network.Remotes["origin"]; string token = sserver.GetValue("AccessToken", ""); if (token == "") { DialogResult choose = MessageBox.Show("Do you want to set a Personal Access Token to avoid input username and password for each push ?", "Access Token didn't exist", MessageBoxButtons.YesNoCancel); if (choose == DialogResult.OK) { MessageBox.Show("Remote origin is not exist, create a repository remotely, something like github, and paste the url into next window form."); SingleInput inputer = new SingleInput(); inputer.Text = "Access Token"; inputer.singleLabel.Text = "Token"; inputer.ConfirmEvent += (sender, accessToken) => { sserver.SetValue("AccessToken", accessToken); inputer.Close(); }; inputer.ShowDialog(); } else if (choose == DialogResult.No) { DoubleInput loginForm = new DoubleInput(); loginForm.Text = "Git login"; loginForm.label1.Text = "Username"; loginForm.input2.PasswordChar = '*'; loginForm.label2.Text = "Passowrd"; loginForm.ConfirmEvent += (sd, username, password) => { if (username == "") { MessageBox.Show("Username can't be empty."); return; } if (password == "") { MessageBox.Show("E-mail can't be empty."); return; } PushOptions options1 = new PushOptions(); options1.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { // TO DO Set AccessToken From Username = username, Password = password }; repo.Network.Push(remote, @"refs/heads/master", options1); loginForm.Close(); }; loginForm.ShowDialog(); } return; } PushOptions options = new PushOptions(); options.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { // TO DO Set AccessToken From Username = token, Password = string.Empty }; repo.Network.Push(remote, @"refs/heads/master", options); DocumentEditor.SetStatusBarEvent(new GH_RuntimeMessage("Push done !")); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }