New to community (problem solved) |
[Jul. 27th, 2006|02:50 pm]
LiveJournal Client Discussions
|
Hi, I've just started working on a client written in C# that will eventually have a gtk# frontend (codename: GerryGiraffe). I'm using the flat interface, as XML-RPC.NET seems to have a sketchy relationship with the mono compiler. Anyhow, I'm working on the login request at the moment. The getchallenge request/response seems to be working just fine. I get an "Invalid password" error message when I attempt to login (and yes, I checked to make sure I had the right password). I'm now wondering if I misunderstood the formula to calculate auth_response. If someone could take a look at my code and verify I'd be quite grateful :)
public static string GetAuthResponseString(string chlg, string pass) { using (System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider()) { // Compute string lengths int lenChlg = Encoding.UTF8.GetByteCount(chlg); int lenPass = Encoding.UTF8.GetByteCount(pass);
// Allocate input buffer byte[] input = new byte[lenChlg + System.Math.Max(16, lenPass)];
// Convert the password into the buffer Encoding.UTF8.GetBytes(pass, 0, pass.Length, input, 0);
// Compute the MD5 hash of the password md5.Initialize(); md5.TransformFinalBlock(input, 0, lenPass);
// Copy the MD5 hash back into the input buffer Array.Copy(md5.Hash, 0, input, lenChlg, md5.Hash.Length);
// Convert the challenge into the input buffer Encoding.UTF8.GetBytes(chlg, 0, chlg.Length, input, 0);
// Length of input int lenHalf = lenChlg + md5.Hash.Length;
// Compute the MD5 hash of the password md5.Initialize(); md5.TransformFinalBlock(input, 0, lenHalf);
return Convert.ToBase64String(md5.Hash); } }
|
|