+139
| [](http://travis-ci.org/a2800276/hexy.js) | ||
| # hexy.js -- utility to create hex dumps | ||
| `hexy` is a javascript library that's easy to use to create hex dumps. It | ||
| works well in node and has cursory browser (more below) support. It contains a | ||
| number of options to configure how the hex dump will end up looking. | ||
| It should create a pleasant looking hex dumb by default: | ||
| var hexy = require('hexy'), | ||
| b = new Buffer("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789") | ||
| console.log(hexy.hexy(b)) | ||
| results in this dump: | ||
| 00000000: 0001 0305 1f0a 0962 6364 6566 6768 696a .......bcdefghij | ||
| 00000010: 6b6c 6d6e 6f70 7172 7374 7576 7778 797a klmnopqrstuvwxyz | ||
| 00000020: 3031 3233 3435 3637 3839 0123456789 | ||
| but it's also possible to configure: | ||
| * Line numbering | ||
| * Line width | ||
| * Format of byte grouping | ||
| * Case of hex decimals | ||
| * Presence of the ASCII annotation in the right column. | ||
| This mean it's easy to generate exciting dumps like: | ||
| 0000000: 0001 0305 1f0a 0962 .... ...b | ||
| 0000008: 6364 6566 6768 696a cdef ghij | ||
| 0000010: 6b6c 6d6e 6f70 7172 klmn opqr | ||
| 0000018: 7374 7576 7778 797a stuv wxyz | ||
| 0000020: 3031 3233 3435 3637 0123 4567 | ||
| 0000028: 3839 89 | ||
| or even: | ||
| 0000000: 00 01 03 05 1f 0a 09 62 63 64 65 66 67 68 69 6a | ||
| 0000010: 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a | ||
| 0000020: 30 31 32 33 34 35 36 37 38 39 | ||
| with hexy! | ||
| Formatting options are configured by passing a `format` object to the `hexy` function: | ||
| var format = {} | ||
| format.width = width // how many bytes per line, default 16 | ||
| format.numbering = n // ["hex_bytes" | "none"], default "hex_bytes" | ||
| format.format = f // ["fours"|"twos"|"none"], how many nibbles per group | ||
| // default "fours" | ||
| format.caps = c // ["lower"|"upper"], default lower | ||
| format.annotate=a // ["ascii"|"none"], ascii annotation at end of line? | ||
| // default "ascii" | ||
| format.prefix=p // <string> something pretty to put in front of each line | ||
| // default "" | ||
| format.indent=i // <num> number of spaces to indent | ||
| // default 0 | ||
| format.html=true // funky html divs 'n stuff! experimental. | ||
| // default: false | ||
| console.log(hexy.hexy(buffer, format)) | ||
| In case you're really nerdy, you'll have noticed that the defaults correspond | ||
| to how `xxd` formats it's output. | ||
| ## Installing | ||
| Either use `npm`: | ||
| npm install hexy | ||
| This will install the lib which you'll be able to use like so: | ||
| var hexy = require("hexy"), | ||
| buf = // get Buffer from somewhere, | ||
| str = hexy.hexy(buf) | ||
| It will also install `hexy` into your path in case you're totally fed up | ||
| with using `xxd`. | ||
| If you don't like `npm`, grab the source from github: | ||
| http://github.com/a2800276/hexy.js | ||
| ## Browser Support | ||
| Basically eveything should work fine in the browser as well, just | ||
| include hexy.js in a script tag, and you'll get `hexy` and `Hexy` stuck | ||
| to the global object (window). | ||
| Some caveats: "Works fine on my system™". Browser support is 'new' and | ||
| not thoroughly tested (... eh, only on chrome [Version: whatever I'm | ||
| currently running]). Under node, I can generally assume that binary data | ||
| is passed in in a sane fashion using buffers, but plain old Javascript | ||
| doesn't really have any datatypes that can handle bytes gracefully. | ||
| Currently only Strings are supported, I'd like to add numeric and typed | ||
| arrays. | ||
| Let me know in case you run into any issues, I'd be happy to find out | ||
| about them. | ||
| ## TODOS | ||
| The current version only pretty prints node Buffer and JS Strings. This | ||
| should be expanded to also do typed arrays, Streams/series of Buffers | ||
| which would be nice so you don't have to collect the whole things you | ||
| want to pretty print in memory, and such. | ||
| I'd like to improve html rendering, e.g. to be able to mouse over the | ||
| ascii annotation and highlight the hex byte and vice versa, improve | ||
| browser integration and set up a proper build & packaging system. | ||
| ## Thanks | ||
| * Thanks to Isaac Schlueter [isaacs] for gratiously lending a hand and | ||
| cheering me up. | ||
| * dodo (http://coderwall.com/dodo) | ||
| * the fine folks at [Travis](http://travis-ci.org/a2800276/hexy.js) | ||
| * radare (https://github.com/radare) | ||
| ## History | ||
| This is a fairly straightforward port of `hexy.rb` which does more or less the | ||
| same thing. You can find it here: | ||
| http://github.com/a2800276/hexy | ||
| in case these sorts of things interest you. | ||
| In case you discover bugs, spelling errors, offer suggestions for | ||
| improvements or would like to help out with the project, you can contact | ||
| me directly (tim@kuriositaet.de). |
+4
-2
| language: node_js | ||
| node_js: | ||
| - 0.6 | ||
| - 0.8 | ||
| - "0.6" | ||
| - "0.8" | ||
| - "0.10" | ||
| - "0.11" |
+43
-24
@@ -48,15 +48,19 @@ //= hexy.js -- utility to create hex dumps | ||
| // var format = {} | ||
| // format.width = width // how many bytes per line, default 16 | ||
| // format.numbering = n // ["hex_bytes" | "none"], default "hex_bytes" | ||
| // format.format = f // ["fours"|"twos"|"none"], how many nibbles per group | ||
| // // default "fours" | ||
| // format.caps = c // ["lower"|"upper"], default lower | ||
| // format.annotate=a // ["ascii"|"none"], ascii annotation at end of line? | ||
| // // default "ascii" | ||
| // format.prefix=p // <string> something pretty to put in front of each line | ||
| // // default "" | ||
| // format.indent=i // <num> number of spaces to indent | ||
| // // default 0 | ||
| // format.html=true // funky html divs 'n stuff! experimental. | ||
| // // default: false | ||
| // format.width = width // how many bytes per line, default 16 | ||
| // format.numbering = n // ["hex_bytes" | "none"], default "hex_bytes" | ||
| // format.format = f // ["fours"|"twos"|"none"], how many nibbles per group | ||
| // // default "fours" | ||
| // format.caps = c // ["lower"|"upper"], default lower | ||
| // format.annotate=a // ["ascii"|"none"], ascii annotation at end of line? | ||
| // // default "ascii" | ||
| // format.prefix=p // <string> something pretty to put in front of each line | ||
| // // default "" | ||
| // format.indent=i // <num> number of spaces to indent | ||
| // // default 0 | ||
| // format.offset // offset into the buffer to start | ||
| // format.length // number of bytes to display | ||
| // format.display_offset // modifiy the starting address by the indicated | ||
| // // number of bytes | ||
| // format.html=true // funky html divs 'n stuff! experimental. | ||
| // // default: false | ||
| // | ||
@@ -148,8 +152,24 @@ // console.log(hexy.hexy(buffer, format)) | ||
| self.caps = config.caps == "upper" ? "upper" : "lower" | ||
| self.annotate = config.annotate == "none" ? "none" : "ascii" | ||
| self.prefix = config.prefix || "" | ||
| self.indent = config.indent || 0 | ||
| self.html = config.html || false | ||
| self.caps = config.caps == "upper" ? "upper" : "lower" | ||
| self.annotate = config.annotate == "none" ? "none" : "ascii" | ||
| self.prefix = config.prefix || "" | ||
| self.indent = config.indent || 0 | ||
| self.html = config.html || false | ||
| self.offset = config.offset || 0 | ||
| self.length = config.length || -1 | ||
| self.display_offset = config.display_offset || 0 | ||
| if (self.offset) { | ||
| if (self.offset < self.buffer.length) { | ||
| self.buffer = self.buffer.slice(self.offset) | ||
| } | ||
| } | ||
| if (self.length !== -1) { | ||
| if (self.length <= self.buffer.length) { | ||
| self.buffer = self.buffer.slice(0,self.length) | ||
| } | ||
| } | ||
| for (var i = 0; i!=self.indent; ++i) { | ||
@@ -189,5 +209,6 @@ self.prefix = " "+self.prefix | ||
| var addr = (i*self.width)+self.offset+self.display_offset; | ||
| if (self.html) { | ||
| odd = i%2 == 0 ? " even" : " odd" | ||
| str += "<div class='"+pad(i*self.width, 8)+odd+"'>" | ||
| str += "<div class='"+pad(addr, 8)+odd+"'>" | ||
| } | ||
@@ -197,3 +218,3 @@ str += self.prefix | ||
| if (self.numbering === "hex_bytes") { | ||
| str += pad(i*self.width, 8) // padding... | ||
| str += pad(addr, 8) // padding... | ||
| str += ": " | ||
@@ -233,8 +254,6 @@ } | ||
| var hex_raw = [] | ||
| for (var i = 0; i<self.buffer.length ; i+=self.width) { | ||
| var begin = i, | ||
| end = i+self.width >= buffer.length ? buffer.length : i+self.width, | ||
| slice = buffer.slice(begin, end), | ||
| end = i+self.width >= self.buffer.length ? self.buffer.length : i+self.width, | ||
| slice = self.buffer.slice(begin, end), | ||
| hex = self.caps === "upper" ? hexu(slice) : hexl(slice), | ||
@@ -241,0 +260,0 @@ raw = slice.toString('ascii') |
+1
-1
| { | ||
| "name" : "hexy", | ||
| "version" : "0.2.5", | ||
| "version" : "0.2.6", | ||
| "description" : "hexdump, binary pretty-printing", | ||
@@ -5,0 +5,0 @@ "author" : "Tim Becker <tim.becker@kuriositaet.de>", |
+21
-1
@@ -61,2 +61,17 @@ var hexy = require("./hexy.js") | ||
| "</div>\n", | ||
| "0000000a: 6162 6364 6566 6768 696a 6b6c 6d6e 6f70 abcdefghijklmnop\n"+ | ||
| "0000001a: 7172 7374 7576 7778 7a79 qrstuvwxzy\n", | ||
| "0000000a: 6162 6364 6566 6768 696a abcdefghij\n", | ||
| "<div class='hexy'>\n"+ | ||
| "<div class='0000000a even'>0000000a: 6162 6364 6566 6768 696a abcdefghij</div>\n"+ | ||
| "</div>\n", | ||
| "0000000a: 3031 3233 3435 3637 3839 6162 6364 6566 0123456789abcdef\n"+ | ||
| "0000001a: 6768 696a 6b6c 6d6e 6f70 7172 7374 7576 ghijklmnopqrstuv\n"+ | ||
| "0000002a: 7778 7a79 wxzy\n", | ||
| "00000014: 6162 6364 6566 6768 696a abcdefghij\n", | ||
| ] | ||
@@ -76,3 +91,8 @@ | ||
| {caps:"upper", numbering:"none", annotate:"none", prefix:"dingdong", format:"twos"}, | ||
| {html:true} | ||
| {html:true}, | ||
| {offset:10}, | ||
| {offset:10, length:10}, | ||
| {offset:10, length:10, html:true}, | ||
| {display_offset: 10}, | ||
| {display_offset: 10, offset:10, length:10}, | ||
| ] | ||
@@ -79,0 +99,0 @@ |
-138
| [](http://travis-ci.org/a2800276/hexy.js) | ||
| = hexy.js -- utility to create hex dumps | ||
| `hexy` is a javascript library that's easy to use to create hex dumps. It | ||
| works well in node and has cursory browser (more below) support. It contains a | ||
| number of options to configure how the hex dump will end up looking. | ||
| It should create a pleasant looking hex dumb by default: | ||
| var hexy = require('hexy'), | ||
| b = new Buffer("\000\001\003\005\037\012\011bcdefghijklmnopqrstuvwxyz0123456789") | ||
| console.log(hexy.hexy(b)) | ||
| results in this dump: | ||
| 00000000: 0001 0305 1f0a 0962 6364 6566 6768 696a .......bcdefghij | ||
| 00000010: 6b6c 6d6e 6f70 7172 7374 7576 7778 797a klmnopqrstuvwxyz | ||
| 00000020: 3031 3233 3435 3637 3839 0123456789 | ||
| but it's also possible to configure: | ||
| * Line numbering | ||
| * Line width | ||
| * Format of byte grouping | ||
| * Case of hex decimals | ||
| * Presence of the ASCII annotation in the right column. | ||
| This mean it's easy to generate exciting dumps like: | ||
| 0000000: 0001 0305 1f0a 0962 .... ...b | ||
| 0000008: 6364 6566 6768 696a cdef ghij | ||
| 0000010: 6b6c 6d6e 6f70 7172 klmn opqr | ||
| 0000018: 7374 7576 7778 797a stuv wxyz | ||
| 0000020: 3031 3233 3435 3637 0123 4567 | ||
| 0000028: 3839 89 | ||
| or even: | ||
| 0000000: 00 01 03 05 1f 0a 09 62 63 64 65 66 67 68 69 6a | ||
| 0000010: 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a | ||
| 0000020: 30 31 32 33 34 35 36 37 38 39 | ||
| with hexy! | ||
| Formatting options are configured by passing a `format` object to the `hexy` function: | ||
| var format = {} | ||
| format.width = width // how many bytes per line, default 16 | ||
| format.numbering = n // ["hex_bytes" | "none"], default "hex_bytes" | ||
| format.format = f // ["fours"|"twos"|"none"], how many nibbles per group | ||
| // default "fours" | ||
| format.caps = c // ["lower"|"upper"], default lower | ||
| format.annotate=a // ["ascii"|"none"], ascii annotation at end of line? | ||
| // default "ascii" | ||
| format.prefix=p // <string> something pretty to put in front of each line | ||
| // default "" | ||
| format.indent=i // <num> number of spaces to indent | ||
| // default 0 | ||
| format.html=true // funky html divs 'n stuff! experimental. | ||
| // default: false | ||
| console.log(hexy.hexy(buffer, format)) | ||
| In case you're really nerdy, you'll have noticed that the defaults correspond | ||
| to how `xxd` formats it's output. | ||
| == Installing | ||
| Either use `npm`: | ||
| npm install hexy | ||
| This will install the lib which you'll be able to use like so: | ||
| var hexy = require("hexy"), | ||
| buf = // get Buffer from somewhere, | ||
| str = hexy.hexy(buf) | ||
| It will also install `hexy` into your path in case you're totally fed up | ||
| with using `xxd`. | ||
| If you don't like `npm`, grab the source from github: | ||
| http://github.com/a2800276/hexy.js | ||
| == Browser Support | ||
| Basically eveything should work fine in the browser as well, just | ||
| include hexy.js in a script tag, and you'll get `hexy` and `Hexy` stuck | ||
| to the global object (window). | ||
| Some caveats: "Works fine on my system™". Browser support is 'new' and | ||
| not thoroughly tested (... eh, only on chrome [Version: whatever I'm | ||
| currently running]). Under node, I can generally assume that binary data | ||
| is passed in in a sane fashion using buffers, but plain old Javascript | ||
| doesn't really have any datatypes that can handle bytes gracefully. | ||
| Currently only Strings are supported, I'd like to add numeric and typed | ||
| arrays. | ||
| Let me know in case you run into any issues, I'd be happy to find out | ||
| about them. | ||
| == TODOS | ||
| The current version only pretty prints node Buffer and JS Strings. This | ||
| should be expanded to also do typed arrays, Streams/series of Buffers | ||
| which would be nice so you don't have to collect the whole things you | ||
| want to pretty print in memory, and such. | ||
| I'd like to improve html rendering, e.g. to be able to mouse over the | ||
| ascii annotation and highlight the hex byte and vice versa, improve | ||
| browser integration and set up a proper build & packaging system. | ||
| == Thanks | ||
| * Thanks to Isaac Schlueter [isaacs] for gratiously lending a hand and | ||
| cheering me up. | ||
| * dodo (http://coderwall.com/dodo) | ||
| == History | ||
| This is a fairly straightforward port of `hexy.rb` which does more or less the | ||
| same thing. You can find it here: | ||
| http://github.com/a2800276/hexy | ||
| in case these sorts of things interest you. | ||
| In case you discover bugs, spelling errors, offer suggestions for | ||
| improvements or would like to help out with the project, you can contact | ||
| me directly (tim@kuriositaet.de). |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
24811
7.39%526
6.69%140
0.72%