public static string GetAuthResponseString(string chlg, string pass)
{
using (System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoSe rviceProvider())
{
// 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);
}
}
New to community (problem solved)
-
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
- 1 comment
- Post a new comment
- 1 comment