Coder Social home page Coder Social logo

hex_dump's Introduction

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.

hex_dump's People

Watchers

 avatar  avatar  avatar

Forkers

ajmihunt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.