diff --git a/asn1.js b/asn1.js index ec51ae8..f29f366 100644 --- a/asn1.js +++ b/asn1.js @@ -37,15 +37,16 @@ Stream.prototype.hexDigits = "0123456789ABCDEF"; Stream.prototype.hexByte = function (b) { return this.hexDigits.charAt((b >> 4) & 0xF) + this.hexDigits.charAt(b & 0xF); }; -Stream.prototype.hexDump = function (start, end) { +Stream.prototype.hexDump = function (start, end, raw) { var s = ""; for (var i = start; i < end; ++i) { s += this.hexByte(this.get(i)); - switch (i & 0xF) { - case 0x7: s += " "; break; - case 0xF: s += "\n"; break; - default: s += " "; - } + if (raw !== true) + switch (i & 0xF) { + case 0x7: s += " "; break; + case 0xF: s += "\n"; break; + default: s += " "; + } } return s; }; @@ -416,6 +417,9 @@ ASN1.prototype.toHexDOM = function (root) { } return node; }; +ASN1.prototype.toHexString = function (root) { + return this.stream.hexDump(this.posStart(), this.posEnd(), true); +}; ASN1.decodeLength = function (stream) { var buf = stream.get(); var len = buf & 0x7F; diff --git a/index.html b/index.html index 5ca721c..19d3eba 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,8 @@