尝试使用 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 登录时捕获了 key 以及加密密码。我的代码使用 C# 和相同 key 生成的密码与 JavaScript 方法生成的密码不匹配。我可以缺少什么?
C# 密码:5d2b9c906608d8381cef4c24ff045be7
密码由网站使用 .js 生成并使用 FIDDLER 捕获:f79a31f85da55aa0e3aca07e06568709
最佳答案
你确定 MD5.js 也使用 ASCII 编码吗?看起来是用UTF8
关于c# - 密码加密-c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6930541/