hex_dump 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/file_dump.rb +1 -1
- data/lib/hex_dump.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd50abd2f6c92170c794c98a0a76650059f4562
|
4
|
+
data.tar.gz: b1af8e3bedc365c38c6a6c20bdcbc47057a46737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcd0fc13029c96cb363c143e5883ad2082de3e7212752193d7f415b77234b6d2dfa6185440841088525664fae77cae1a67fa13831dc5a2fd04a0de85066efb38
|
7
|
+
data.tar.gz: 89b91245fcddcb2d88c46df659b8f2583a4cef993f21e2cf2f38e71d8d8c044b5c467b9597afac160f993ed9537ae60d9703f080c7d302018d42a0e929b66b8e
|
data/examples/file_dump.rb
CHANGED
data/lib/hex_dump.rb
CHANGED
@@ -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 :
|
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) + "
|
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.
|
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-
|
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
|