Skip to content
Advertisement

Is there a way to generate same Hmac hash output from PHP as done with nodejs?

Following is my nodejs function for creating HMAC hash –

JavaScript
JavaScript

Following is my PHP equivalent code for generating above mentioned output –

JavaScript
JavaScript

From the outputs, it is clear that in nodejs I am getting replacement characters whereas in PHP it appears as a question mark.

I am trying to generate exactly the same output from my PHP code so that when the outputs are rehashed it should be the same.

Advertisement

Answer

I’ll update my answer to reflect your code changes. Thanks to @Topaco for resolving the issue.

php

JavaScript

node

JavaScript

php output:

JavaScript

Node.js output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement