Module: RubyHome::HexHelper

Defined in:
lib/ruby_home/hex_helper.rb

Class Method Summary collapse

Class Method Details

.pack_hex_string(input) ⇒ Object



11
12
13
# File 'lib/ruby_home/hex_helper.rb', line 11

def self.pack_hex_string(input)
  [input].pack("H*")
end

.pad(input, pad_length: 24) ⇒ Object



3
4
5
# File 'lib/ruby_home/hex_helper.rb', line 3

def self.pad(input, pad_length: 24)
  pack_hex_string(unpack_hex_string(input).rjust(pad_length, "0"))
end

.unpack_hex_string(input) ⇒ Object



7
8
9
# File 'lib/ruby_home/hex_helper.rb', line 7

def self.unpack_hex_string(input)
  input.to_s.unpack1("H*")
end