JavaScript generic ASN.1 parser (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve hex dump capabilities of ASN.1 nodes.

+11 -4
+11 -4
asn1.js
··· 78 78 hexByte(b) { 79 79 return hexDigits.charAt((b >> 4) & 0xF) + hexDigits.charAt(b & 0xF); 80 80 } 81 - hexDump(start, end, raw) { 81 + /** Hexadecimal dump. 82 + * @param type 'raw', 'byte' or 'dump' */ 83 + hexDump(start, end, type = 'dump') { 82 84 let s = ''; 83 85 for (let i = start; i < end; ++i) { 86 + if (type == 'byte' && i > start) 87 + s += ' '; 84 88 s += this.hexByte(this.get(i)); 85 - if (raw !== true) 89 + if (type == 'dump') 86 90 switch (i & 0xF) { 87 91 case 0x7: s += ' '; break; 88 92 case 0xF: s += '\n'; break; ··· 517 521 posLen() { 518 522 return this.stream.pos + this.tagLen; 519 523 } 520 - toHexString() { 521 - return this.stream.hexDump(this.posStart(), this.posEnd(), true); 524 + /** Hexadecimal dump of the node. 525 + * @param type 'raw', 'byte' or 'dump' */ 526 + toHexString(type = 'raw') { 527 + return this.stream.hexDump(this.posStart(), this.posEnd(), type); 522 528 } 529 + /** Base64 dump of the node. */ 523 530 toB64String() { 524 531 return this.stream.b64Dump(this.posStart(), this.posEnd()); 525 532 }