From abce2cc95bafb4fa19332fe2682d26bb59b14a40 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 22 Nov 2018 22:38:41 -0700 Subject: [PATCH] add length in hex to tpl comment --- lib/asn1.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/asn1.js b/lib/asn1.js index 6668931..6407bf9 100644 --- a/lib/asn1.js +++ b/lib/asn1.js @@ -95,7 +95,7 @@ ASN1.parse = function parseAsn1(buf, depth) { if (0x80 & asn1.length) { asn1.lengthSize = 0x7f & asn1.length; // I think that buf->hex->int solves the problem of Endianness... not sure - asn1.length = parseInt(buf.slice(index, index + asn1.lengthSize).toString('hex'), 16); + asn1.length = parseInt(Enc.bufToHex(buf.slice(index, index + asn1.lengthSize)), 16); index += asn1.lengthSize; } @@ -173,12 +173,12 @@ ASN1.tpl = function (asn1) { } else if (0x03 === asn1.type) { str += "ASN1.BitStr("; } else { - str += "ASN1('" + Buffer.from([asn1.type]).toString('hex') + "', "; + str += "ASN1('" + Enc.numToHex(asn1.type) + "', "; } if (!asn1.children) { val = Buffer.from(asn1.value || ''); - vars.push("// " + val.byteLength + " bytes\nvar tpl" + i + " = '" - + val.toString('hex') + "';"); + vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '" + + Enc.bufToHex(val) + "';"); str += "tpl" + i + ")"; return ; }