This commit is contained in:
2023-03-28 08:22:08 +02:00
parent 35db2e56d4
commit f08b2e91c8
5 changed files with 62 additions and 12 deletions

View File

@@ -1,10 +1,11 @@
using System.Text;
using System.Diagnostics;
using System.Text;
namespace Password_Generator
{
static class Generator
static class PasswordGenerator
{
public static string New(int length, bool no_symbols = false)
private static string RandomStr(int length, bool no_symbols = false)
{
StringBuilder builder = new StringBuilder();
Random rnd = new Random();
@@ -30,5 +31,39 @@ namespace Password_Generator
return builder.ToString();
}
public static string New(int length, bool no_symbols = false)
{
File.WriteAllText(@".\\", RandomStr(length, no_symbols));
try
{
Process proc = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "echo", //TODO: pipe the return value of RandomStr to gpg with the --quiet --encrypt --recipient {recipient} flags
//Arguments = $"--quiet --decrypt {filePath}",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
Clipboard.SetText(line);
//Process.Start("./ToastNotification.exe", $"\"{fileName} decrypted\" \"Password copied to clipboard\"");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return null;
}
}
}