hex2bin in node.js

Basically it’s all over-engineered and does not work well.

responses are out of alignment and though text-wise they are the same bit wise everything is all over the place :

curl http://phpimpl.domain.com/testhex.php | xxd

00000000: de56 a735 4739 c01d f2dc e14b ba30 8af0 .Q.%G9.....;.0..

curl http://nodejs.domain.com/ | xxd

00000000: c39e 56c2 a725 4739 c380 c3ad c3b1 c39c ..Q..%G9........
 00000010: c3a1 37c2 6b30 c28f c3b0 ..;..0....

The proper way to implement this in node is :

function hex2bin(hex){
return new Buffer(hex,”hex”);
}

curl http://nodejs.domain.com/ | xxd

00000000: de56 a735 4739 c01d f2dc e14b ba30 8af0 .Q.%G9…..;.0..

nJoy 😉

Write a Reply or Comment

Your email address will not be published.