hex_dump 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 061d35cd6d8ab4ca7e1ea1839883b63f4a5f539d
4
- data.tar.gz: a9c19068b15f30fd9103c34ac6414201d459de5c
3
+ metadata.gz: 8dd50abd2f6c92170c794c98a0a76650059f4562
4
+ data.tar.gz: b1af8e3bedc365c38c6a6c20bdcbc47057a46737
5
5
  SHA512:
6
- metadata.gz: 4286c9c73eeaea2bfea74a812bf5505b2fadbbf5c8ecb53737f0301a099d8b1c15c099d489a679932f233f7b268f1fc969ab5d7287c871df1b071bd2c23042bf
7
- data.tar.gz: 0da6d609b65fa05f33354e5210e748f52fdcca600bfef0f82a91cdd32311bcf05cd6608a480ea4445da63dc9bdc031688221da825e06b240785b8c40d878276b
6
+ metadata.gz: fcd0fc13029c96cb363c143e5883ad2082de3e7212752193d7f415b77234b6d2dfa6185440841088525664fae77cae1a67fa13831dc5a2fd04a0de85066efb38
7
+ data.tar.gz: 89b91245fcddcb2d88c46df659b8f2583a4cef993f21e2cf2f38e71d8d8c044b5c467b9597afac160f993ed9537ae60d9703f080c7d302018d42a0e929b66b8e
@@ -2,7 +2,7 @@
2
2
  # to run this file enter this on command line:
3
3
  # $ ruby file_dump.rb
4
4
 
5
- require 'hex_dump'
5
+ require '../lib/hex_dump.rb'
6
6
 
7
7
  contents = File.read("img.png") # read file into a string
8
8
 
@@ -20,9 +20,10 @@ module HexDump
20
20
  WHITE = 37
21
21
 
22
22
  # Takes a buffer and displays it in hexadecimal in a format described by the options
23
- # The optional options are :line_size and :hex_color
23
+ # The optional options are :line_size, :hex_color and :delimiter
24
24
  # :line_size sets the size (width) of the hex display. Can be 16(default), 24, 32 or 64
25
25
  # :hex_color sets the color of the foreground text. Can be a number between 30 to 37 (see codes above)
26
+ # :delimiter sets the boundary between the line numbers and the hex values
26
27
  # @param buffer [String] The actual binary data/string that is to be displayed in hex.
27
28
  # @param options [Hash] This can be blank (in that case defaults options will be used).
28
29
  # Otherwise a hash providing any of the settings that are to be changed.
@@ -31,10 +32,11 @@ module HexDump
31
32
  # @return [String] A string containing the entire hexdump.
32
33
  def self.print(buffer = "", options = {})
33
34
  # merge(and overwrite) whatsoever options were passed by user
34
- options = {line_size: 16, hex_color: WHITE }.merge(options)
35
+ options = {line_size: 16, hex_color: WHITE, delimiter: ":" }.merge(options)
35
36
 
36
37
  line_size = options[:line_size]
37
38
  hex_color = options[:hex_color]
39
+ delimiter = options[:delimiter]
38
40
 
39
41
  line_size = 16 unless [16, 24, 32, 64].include?(line_size) # prevent user providing arbit line_size
40
42
 
@@ -44,7 +46,7 @@ module HexDump
44
46
  buffer_length = buffer.length
45
47
 
46
48
  while byte_number < buffer_length
47
- line_number = (sprintf '%08x', byte_number) + ": " # print byte number padded with zeros on left
49
+ line_number = (sprintf '%08x', byte_number) + delimiter + " " # print byte number padded with zeros on left
48
50
 
49
51
  if (buffer_length - byte_number) >= line_size
50
52
  characters = buffer.byteslice(byte_number, line_size) # get a line size worth of characters
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hex_dump
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shivam Patel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-17 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem allows programmers to hexdump arbitary strings and binaries.
14
14
  Helpful for your reverse engineering scripts. Has options like line_width and hex_colors