I am migrating from .net core to reactjs and need to calculate hash. I stuck in this code where results are not equal. Here is the code of .net, _normKey and inputBytes are byte arrays and result stored in hash is also byte array. How can i convert this into reactjs.
_normkey = [150, 68, 231, 118, 4, 194, 153, 75, 25, 195, 123, 71, 133, 198, 103, 2, 169, 52, 8, 149, 68, 220, 132, 39, 183, 158, 132, 105, 77, 48, 18, 243, 211, 178, 144, 109, 73, 36, 254, 215, 175, 134, 92, 49, 5, 216, 170, 123, 75, 26, 232, 181, 129, 76, 22, 223, 167, 110, 52, 249, 189, 128, 66, 3];
inputBytes = [49, 46, 48, 53, 51, 46, 48, 46, 55, 52, 51, 48, 52, 50, 49, 54, 65, 45, 67, 51, 68, 70, 45, 52, 55, 48, 66, 45, 66, 68, 67, 48, 45, 67, 57, 57, 55, 48, 54, 67, 51, 48, 65, 65, 69, 49, 46, 48, 53, 73, 110, 116, 101, 103, 114, 97, 65, 80, 73, 48, 101, 112, 97, 108, 101, 110, 122, 117, 101, 108, 97, 50, 64, 105, 110, 116, 101, 103, 114, 97, 112, 97, 114, 107, 105, 110, 103, 46, 99, 111, 109, 49, 50, 51, 52, 53, 49, 48, 48, 48, 55, 49, 51, 54, 49, 51, 53, 46, 46]
byte[] hash = new HMACSHA256(_normKey).ComputeHash(inputBytes);
if (hash.Length >= 8)
{
StringBuilder sb = new StringBuilder();
for (int i = hash.Length - 8; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
strRes = sb.ToString();
}
Here is the code of Reactjs
var hash = CryptoJS.HmacSHA256(_normKey.toString(), inputBytes.toString());
console.log(hash)
When I pass _normkey and inputBytes without toString, It throws error key.clamps is not a function