Project

hex_dump

0.0
No commit activity in last 3 years
No release in over 3 years
This gem allows programmers to hexdump arbitary strings and binaries. Helpful for your reverse engineering scripts. Has options like line_width and hex_colors which can help customize the format in which the resultant hexadecimal dump of the string or binary is displayed.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Hex Dump

This is a ruby library (and a gem) which facilitates printing a hexadecimal dump of a given binary/string.

The example directory has sample usage of the library.

This is tested on Ruby versions 1.9.3 and above

Usage

The usage of this library is very straightforward. Usage examples are shown below.

Get code

Install the gem (preferred way)

gem install hex_dump

of clone the code from github

git clone https://github.com/shivampatel/hex_dump.git

Require the gem

require 'hex_dump' 

Obtain the binary/string which you want to see in hex

contents = File.read("your_file.jpg") # dumping file
contents = socket.recv(1024) # or data from a network socket

View hex dump

# Display hex with default options

HexDump.print contents
# display hex in color Yellow.

HexDump.print contents, options={hex_color: HexDump::CYAN}
# display hex with line width 24 and foreground color green

HexDump.print contents, options={line_size: 24, hex_color: HexDump::GREEN}

Hex Dump options

HexDump takes options in the form of options hash. These are the options that can be passed to HexDump:

hex_color

Default is white. These are the values that hex_color can take:

  • HexDump::CYAN
  • HexDump::BLACK
  • HexDump::RED
  • HexDump::GREEN
  • HexDump::YELLOW
  • HexDump::BLUE
  • HexDump::MAGENTA
  • HexDump::CYAN
  • HexDump::WHITE

line_size

line_size can be 16, 24, 32 or 64. Default is 16

delimiter

Delimiter is the character that delimits the line numbers and the hex characters. Default is ":". Users can pass any character or string to denote a different delimiter.

One use case of having different delimiters is to differentiate between different streams of data. Eg. differentiate between SSL data and plain text data in a hex stream of network but having delimiters as 'S' and ':' respectively.