Simplified password generation.
The class is called PasswordGenerator, so that's what it will *only* do
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using System.Text;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Password_Generator
|
namespace Password_Generator
|
||||||
{
|
{
|
||||||
@@ -32,10 +31,8 @@ namespace Password_Generator
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string New(int length, bool no_symbols = false)
|
public static string New(string recipient, int length, bool no_symbols = false)
|
||||||
{
|
{
|
||||||
File.WriteAllText(@".\\", RandomStr(length, no_symbols));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process proc = new Process()
|
Process proc = new Process()
|
||||||
@@ -43,7 +40,7 @@ namespace Password_Generator
|
|||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "echo", //TODO: pipe the return value of RandomStr to gpg with the --quiet --encrypt --recipient {recipient} flags
|
FileName = "echo", //TODO: pipe the return value of RandomStr to gpg with the --quiet --encrypt --recipient {recipient} flags
|
||||||
//Arguments = $"--quiet --decrypt {filePath}",
|
Arguments = $"{RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
@@ -51,19 +48,20 @@ namespace Password_Generator
|
|||||||
};
|
};
|
||||||
|
|
||||||
proc.Start();
|
proc.Start();
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
while (!proc.StandardOutput.EndOfStream)
|
while (!proc.StandardOutput.EndOfStream)
|
||||||
{
|
{
|
||||||
string line = proc.StandardOutput.ReadLine();
|
builder.Append(proc.StandardOutput.ReadLine());
|
||||||
Clipboard.SetText(line);
|
return builder.ToString();
|
||||||
//Process.Start("./ToastNotification.exe", $"\"{fileName} decrypted\" \"Password copied to clipboard\"");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user