【发布时间】:2016-07-01 04:55:00
【问题描述】:
我在 C# 和 node.js 中生成一个哈希字符串,但不断得到两个不同的结果......
在 C# 中:
byte[] secretKeyBytes = Convert.FromBase64String('some_secret_key');
byte[] requestValuesSignature = Encoding.UTF8.GetBytes('teststring');
HMACSHA256 testHash = new HMACSHA256(secretKeyBytes);
byte[] = hashedBytes = testHash.ComputeHash(requestValuesSignature);
string hash1 = Convert.ToBAse64String(hashedBytes);
Console.WriteLine(hash1);
在 Node.js 中:
var hash2 = crypto.createHmac('SHA256', 'some_secret_key').update('teststring', 'utf8').digest('base64');
有人可以帮忙吗?
提前致谢!
【问题讨论】:
-
如果您提供结果会有所帮助,请添加到问题中。
标签: javascript c# node.js cryptography