Implementing ProcessBuilder

This commit is contained in:
2023-03-29 14:38:59 +02:00
parent dfd8c1d462
commit edc81b661f
2 changed files with 12 additions and 2 deletions

View File

@@ -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();
}
}

View File

@@ -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}");
}
}
}