Talking to htpasswd.exe
-
Can anyone see what I'm doing wrong here? All I want to do is generate a password with htpasswd.exe and it looked easy enough but it just gets stuck at ReadLine() :confused:
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = Path.Combine(Application.StartupPath, "htpasswd.exe");
ps.Arguments = "-n test";
ps.CreateNoWindow = true;
ps.UseShellExecute = false;
ps.RedirectStandardInput = true;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;Process proc = new Process();
proc.StartInfo = ps;
proc.Start();proc.StandardInput.WriteLine("testing");
proc.StandardInput.WriteLine("testing");string line = proc.StandardOutput.ReadLine();
proc.Close();
http://johanmartensson.se - Home of MPEG4Watcher
-
Can anyone see what I'm doing wrong here? All I want to do is generate a password with htpasswd.exe and it looked easy enough but it just gets stuck at ReadLine() :confused:
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = Path.Combine(Application.StartupPath, "htpasswd.exe");
ps.Arguments = "-n test";
ps.CreateNoWindow = true;
ps.UseShellExecute = false;
ps.RedirectStandardInput = true;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;Process proc = new Process();
proc.StartInfo = ps;
proc.Start();proc.StandardInput.WriteLine("testing");
proc.StandardInput.WriteLine("testing");string line = proc.StandardOutput.ReadLine();
proc.Close();
http://johanmartensson.se - Home of MPEG4Watcher
I know nothing about 'htpasswd', but generally a ReadLine() method expects a carriage return. Did you hit return?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Can anyone see what I'm doing wrong here? All I want to do is generate a password with htpasswd.exe and it looked easy enough but it just gets stuck at ReadLine() :confused:
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = Path.Combine(Application.StartupPath, "htpasswd.exe");
ps.Arguments = "-n test";
ps.CreateNoWindow = true;
ps.UseShellExecute = false;
ps.RedirectStandardInput = true;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;Process proc = new Process();
proc.StartInfo = ps;
proc.Start();proc.StandardInput.WriteLine("testing");
proc.StandardInput.WriteLine("testing");string line = proc.StandardOutput.ReadLine();
proc.Close();
http://johanmartensson.se - Home of MPEG4Watcher
The exe basically generates md5 hashed passwords IIRC. That can be done in code without needing that exe. Search for MD5 c# and you'll find many results. Here are a couple: http://www.spiration.co.uk/post/1203/MD5%20in%20C%23%20-%20works%20like%20php%20md5()%20example[^] http://blogs.msdn.com/csharpfaq/archive/2006/10/09/How-do-I-calculate-a-MD5-hash-from-a-string_3F00_.aspx[^]
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
The exe basically generates md5 hashed passwords IIRC. That can be done in code without needing that exe. Search for MD5 c# and you'll find many results. Here are a couple: http://www.spiration.co.uk/post/1203/MD5%20in%20C%23%20-%20works%20like%20php%20md5()%20example[^] http://blogs.msdn.com/csharpfaq/archive/2006/10/09/How-do-I-calculate-a-MD5-hash-from-a-string_3F00_.aspx[^]
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)True it generates a sort of md5 hashed passwords, but htpasswd.exe is a part of Apache webserver and they use a modified version of md5.
http://johanmartensson.se - Home of MPEG4Watcher
-
I know nothing about 'htpasswd', but generally a ReadLine() method expects a carriage return. Did you hit return?
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
The WriteLine adds a carriage return so that part is ok. I found what I had missed, the command-prompt needed to exit before it returned the result. So adding this before reading the output solved it:
proc.StandardInput.WriteLine("exit");
http://johanmartensson.se - Home of MPEG4Watcher