Switched messageboxes to custom events

This commit is contained in:
2023-04-02 22:40:47 +02:00
parent 18e4bbf535
commit ad88e3ebe1
2 changed files with 7 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace Common;
public static class PasswordGenerator
{
public static Error? ExceptionOccured;
private static string RandomStr(int length, bool no_symbols = false)
{
StringBuilder builder = new StringBuilder();
@@ -32,6 +33,8 @@ public static class PasswordGenerator
public static string? New(string recipient, int length, bool no_symbols = false)
{
return new ProcessBuilder().GetOutput("cmd.exe", $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}");
ProcessBuilder pb = new ProcessBuilder();
pb.ProcessFailed += (e) => ExceptionOccured?.Invoke(e);
return pb.GetOutput("cmd.exe", $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}");
}
}