HMAC changes according to node version (paybox mod

2019-09-16 11:58发布

问题:

I am using https://www.npmjs.com/package/paybox and I need to upgrade my node version (from 5.6 to 6+)

As you can see below, the generateHMAC creates a hash that differs if I change my version of node.

Can you help me understand this, and tell me if it can compromise something (maybe it is OK? several hashes could be OK?)

Here is my code snippet:

"use strict";
const paybox = require('./node_modules/paybox/lib/paybox.js')

let computed_hmac = paybox.generateHMAC({a:12}, 'aaaaaaabbbbbbbcccccccc1111122233');
console.log(computed_hmac);

Here is the result with version 5.6.0 of node

$ node -v
v5.6.0
$ node testPaybox.sh
D0643202B4AF2A23055933597ACB6CB024A26F7DEBC4798B5AB0AC6242D1C9D0F1BC481B86CEF0505546D1D30F4A6807D193A00E5A4E81F874447BC0EE040D87

and with any version from 6.11.1 (up to the latest)

$ node -v
v6.11.1
orange:easy-sport-web dao$ node testPaybox.sh
E5A70879F038F35103524AB5157205C8169DDBAD3B41465D19690F87C64FACB6E098C283812B6D6AC79F23AE7A7DC2B0EEEDF5796E4BFC9DE87A517AFCE7E049

回答1:

Because of https://stackoverflow.com/a/45582931/1566975 prefer using the fork https://github.com/daohodac/node-paybox that solves the issue