System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] bytes = File.ReadAllBytes("C:\\xx.mac");
byte[] hash;
byte [] messageBytes;
HMACSHA256 hmacsha256 = new HMACSHA256(bytes);
messageBytes = encoding.GetBytes(message);//this is the string which will be hashed
hash = hmacsha256.ComputeHash(messageBytes);
string s = Convert.ToBase64String(hash);
如何使用共享二进制密钥来散列字符串。我已共享存储在文件中的二进制键,因此我想读取文件的内容并使用它来散列字符串。 我希望在C#中实现这一点。我该怎么办?
编辑:生成的哈希与支付处理器生成的哈希不匹配。我们都使用相同的字符串来哈希