Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexy

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexy

hexdump, binary pretty-printing

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-63.52%
Maintainers
1
Weekly downloads
 
Created
Source

= hexy.js -- utility to create hex dumps

hexy is a javascript (node) library that's easy to use to create hex dumps from within node. It contains a number of options to configure how the hex dumb 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:

0000000: 00 01 03 05 1f 0a 09 62   63 64 65 66 67 68 69 6a  .......b cdefghij 
0000010: 6b 6c 6d 6e 6f 70 71 72   73 74 75 76 77 78 79 7a  klmnopqr stuvwxyz 
0000020: 30 31 32 33 34 35 36 37   38 39                    01234567 89

but it's also possible to configure:

  • Line numbering
  • Line width
  • Format
  • Case of hex decimals
  • Presence of the ASCII annotation in the right column.

This mean you can do 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

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

== TODOS

The current version only pretty prints Buffers. Which probably means it can only be used from within node. What's more important what it doesn't support: Strings (which would be nice for the sake of completeness) and 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. hexy is probably most useful for debugging and getting binary protocol stuff working, so that's probably not an too much of an issue.

== 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.

== Mail

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).

FAQs

Package last updated on 03 May 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc