我有来自ONVIF 程序员指南的以下文档
我目前正在尝试使用指南中给出的相同条目来重现结果摘要...
这是我的代码:
private string GenerateHashedPassword(string nonce, string created, string password)
{
byte[] nonceBytes = Encoding.UTF8.GetBytes(nonce);
byte[] createdBytes = Encoding.UTF8.GetBytes(created);
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
byte[] combined = new byte[createdBytes.Length + nonce.Length + passwordBytes.Length];
//N-C-P
Buffer.BlockCopy(nonceBytes, 0, combined, 0, nonceBytes.Length);
Buffer.BlockCopy(createdBytes, 0, combined, nonceBytes.Length, createdBytes.Length);
Buffer.BlockCopy(passwordBytes, 0, combined, nonceBytes.Length + createdBytes.Length, passwordBytes.Length);
return Convert.ToBase64String(SHA1.Create().ComputeHash(combined));
}
当我使用我的功能时:
string digestPassword = GenerateHashedPassword("LKqI6G/AikKCQrN0zqZFlg==","2010-09-16T07:50:45Z","userpassword");//Values from guide
我的函数返回的结果与指南中的结果不同...
我的功能有什么问题??为什么我不能得到相同的输出?