Bilal Djaghout
Bilal Djaghout

Reputation: 186

PHP pack function alternative for Node.js

I'm trying to connect to PayBox payment service. They propose a PHP solution, but I'm using Nodejs. In their solution they use PHP pack function of which I can't find an equivalent in Node.js.

This is the target:

$binKey = pack("H*", $secretKeyTest);

I found a package Hipack but it has couple of issues.

Upvotes: 3

Views: 4283

Answers (1)

rsp
rsp

Reputation: 111446

If you need to convert a hexadecimal string into a binary buffer, then something like this may work for you:

var binKey =  Buffer.from(secretKeyTest, "hex");

For more info on how to use buffers in Node, see:

Upvotes: 4

Related Questions