尝试使用HTTPWebRequest模拟文件上传。客户端使用的是此开发者的Md5.js MD5.js
在我的C#代码中,我生成加密字符串如下:
public string PasswordHash(string password, string Key)
{
ASCIIEncoding encoding = new ASCIIEncoding();
HMACMD5 hmacmd = new HMACMD5(encoding.GetBytes(Key));
byte[] bytes = encoding.GetBytes(password);
byte[] byteBuffer= hmacmd.ComputeHash(bytes);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < buffer3.Length; i++)
{
builder.Append(byteBuffer[i].ToString("x2"));
}
return builder.ToString().ToLower();
}
正在使用的MD5.js函数如下:
function hex_hmac_md5(k, d) {
return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
}
使用Fiddler,我捕获了IE登录时使用的密钥以及加密的密码。使用C#代码生成的密码与JavaScript方法生成的密码不匹配。我可能遗漏了什么?
C#密码:
5d2b9c906608d8381cef4c24ff045be7
;通过JS生成并使用FIDDLER捕获的密码:f79a31f85da55aa0e3aca07e06568709
。