2017-05-22 23:35:55 +02:00
|
|
|
using System;
|
2017-09-10 20:00:26 +02:00
|
|
|
using System.Diagnostics;
|
2017-05-22 23:35:55 +02:00
|
|
|
|
|
|
|
namespace SteamGuard
|
|
|
|
{
|
|
|
|
public static class Utils
|
|
|
|
{
|
|
|
|
public static string ReadLineSecure()
|
|
|
|
{
|
2017-09-10 20:00:26 +02:00
|
|
|
// Have bash handle the password input, because apparently it's impossible in C#,
|
|
|
|
// and we don't need to worry about windows compatibility.
|
|
|
|
string bash_cmd = @"read -s -p ""Password: "" password; echo $password";
|
|
|
|
Process p = new Process();
|
|
|
|
p.StartInfo.UseShellExecute = false;
|
|
|
|
p.StartInfo.FileName = "bash";
|
|
|
|
p.StartInfo.Arguments = string.Format("-c '{0}'", bash_cmd);
|
|
|
|
p.StartInfo.RedirectStandardOutput = true;
|
|
|
|
p.Start();
|
2017-05-22 23:35:55 +02:00
|
|
|
|
2017-09-10 20:00:26 +02:00
|
|
|
p.WaitForExit();
|
|
|
|
Console.WriteLine();
|
|
|
|
return p.StandardOutput.ReadToEnd().Trim();
|
2017-05-22 23:35:55 +02:00
|
|
|
}
|
2018-03-27 23:48:22 +02:00
|
|
|
|
|
|
|
public static void Verbose(object obj)
|
|
|
|
{
|
|
|
|
Verbose(obj.ToString(), null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Verbose(string format, params object[] arg)
|
|
|
|
{
|
|
|
|
if (Program.Verbose)
|
|
|
|
{
|
|
|
|
Console.WriteLine(format, arg);
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 23:35:55 +02:00
|
|
|
}
|
|
|
|
}
|