From edc81b661fae5aea1f67a112cf41f35d33596334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Wed, 29 Mar 2023 14:38:59 +0200 Subject: [PATCH] Implementing ProcessBuilder --- Password Manager/MainForm.cs | 10 ++++++++++ Password Manager/PasswordGenerator.cs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Password Manager/MainForm.cs b/Password Manager/MainForm.cs index 2cd37e6..e8ea4fe 100644 --- a/Password Manager/MainForm.cs +++ b/Password Manager/MainForm.cs @@ -43,8 +43,18 @@ namespace Password_Manager Close(); } + private void CopyAndNotify(string line) + { + Clipboard.SetText(line); + + ProcessBuilder.ProcessFailed += (e) => MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + ProcessBuilder.Run("./ToastNotification.exe", $"\"{fileName} decrypted\" \"Password copied to clipboard\""); + } + private void Decrypt(object sender, EventArgs e) { + ProcessBuilder.ProcessFailed += (e) => MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + CopyAndNotify(ProcessBuilder.GetOutput("gpg.exe", $"--quiet --decrypt {PathRequest()}\\{ResultList.Text}")); Close(); } } diff --git a/Password Manager/PasswordGenerator.cs b/Password Manager/PasswordGenerator.cs index 83a2f0c..8c61819 100644 --- a/Password Manager/PasswordGenerator.cs +++ b/Password Manager/PasswordGenerator.cs @@ -1,5 +1,4 @@ - -namespace Password_Generator +namespace Password_Generator { static class PasswordGenerator { @@ -32,6 +31,7 @@ namespace Password_Generator public static string? New(string recipient, int length, bool no_symbols = false) { + return ProcessBuilder.GetOutput("cmd.exe" $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}"); } } }