hexl

1.0.1 • Public • Published

Hexl

Generate or display a hex dump

Quickstart

npm install hexl
const Hexl = require('hexl');

// return the hexdump as a string
Hexl.hexl(<buffer|string>, [caption]);

// output the hexdump directly
Hexl.log(<buffer|string>, [caption]);

Example

const Hexl = require('hexl');

let s = new Buffer([
  00, 01, 02, 03, 04, 05, 06, 07, 08, 09,
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
  40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
  50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
  60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
  70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
  90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
  100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
  110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
  120, 121, 122, 123, 124, 125, 126, 127
  ]);

Hexl.log(s, 'ascii table');

-----------------------------------------
ascii table
-----------------------------------------
0007 | 00 01 02 03 04 05 06 07 | ........
000f | 08 09 0a 0b 0c 0d 0e 0f | ........
0017 | 10 11 12 13 14 15 16 17 | ........
001f | 18 19 1a 1b 1c 1d 1e 1f | ........
0027 | 20 21 22 23 24 25 26 27 |  !"#$%&'
002f | 28 29 2a 2b 2c 2d 2e 2f | ()*+,-./
0037 | 30 31 32 33 34 35 36 37 | 01234567
003f | 38 39 3a 3b 3c 3d 3e 3f | 89:;<=>?
0047 | 40 41 42 43 44 45 46 47 | @ABCDEFG
004f | 48 49 4a 4b 4c 4d 4e 4f | HIJKLMNO
0057 | 50 51 52 53 54 55 56 57 | PQRSTUVW
005f | 58 59 5a 5b 5c 5d 5e 5f | XYZ[\]^_
0067 | 60 61 62 63 64 65 66 67 | `abcdefg
006f | 68 69 6a 6b 6c 6d 6e 6f | hijklmno
0077 | 70 71 72 73 74 75 76 77 | pqrstuvw
007f | 78 79 7a 7b 7c 7d 7e 7f | xyz{|}~.
-----------------------------------------

Package Sidebar

Install

npm i hexl

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • simonswain