我们有一个 python 网络服务。它需要一个哈希作为参数。python中的哈希是这样生成的。
hashed_data = hmac.new("ant", "bat", hashlib.sha1)
print hashed_data.hexdigest()
现在,这就是我从 C# 生成哈希的方式。
ASCIIEncoding encoder = new ASCIIEncoding();
Byte[] code = encoder.GetBytes("ant");
HMACSHA1 hmSha1 = new HMACSHA1(code);
Byte[] hashMe = encoder.GetBytes("bat");
Byte[] hmBytes = hmSha1.ComputeHash(hashMe);
Console.WriteLine(Convert.ToBase64String(hmBytes));
但是,我得出了不同的结果。
我应该更改散列的顺序吗?
谢谢,
乔恩