Janina (trinbellwoods) wrote in lj_clients,

New to community (problem solved)

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.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.TransformFinalBlock(input, 0, lenHalf);

return Convert.ToBase64String(md5.Hash);


  • 302: lj_dev

    In the interests of consolidating all LiveJournal development-related discussion, we're going to be closing down this community. The same…

  • Plain text to LJ

    I have an old blog from xanga that's in html/plain text and I want to move it over here. Which client would be the best to do this? I also want to…

  • ljKlient 0.2.0 Preview Release 1

    Today marks another milestone in the development of ljKlient — as the first preview of the 0.2 series is released.  Please go to the project…

  • Post a new comment


    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 1 comment