From 71960b48ce65c1870deb21c2d7d394d3f576bf97 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 21 Nov 2018 18:49:57 -0700 Subject: [PATCH] output parsed info with tabs --- bin/rasha.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/rasha.js b/bin/rasha.js index a561539..f35e338 100755 --- a/bin/rasha.js +++ b/bin/rasha.js @@ -59,8 +59,17 @@ function ASN1(buf, depth) { */ var asn1 = ASN1.parse(buf); +var ws = ''; +function write(asn1) { + console.log(ws, 'ch', Buffer.from([asn1.type]).toString('hex'), asn1.length); + if (!asn1.children) { + return; + } + asn1.children.forEach(function (a, i) { + ws += '\t'; + write(a); + ws = ws.slice(1); + }); +} console.log(asn1); -console.log(asn1.type, asn1.length); -asn1.children.forEach(function (a, i) { - console.log(i, 'ch', Buffer.from([a.type]).toString('hex'), a.length); -}); +write(asn1);