class Hashtastic::Utils

Public Class Methods

hex?(value) click to toggle source
# File lib/hashtastic/utils.rb, line 12
def hex?(value)
  pattern = /^[[:xdigit:]]+$/
  return false if value[0..1] != '0x'

  return value[2..-1].match?(pattern)
end
hex_to_ascii(hex) click to toggle source
# File lib/hashtastic/utils.rb, line 6
def hex_to_ascii(hex)
  value = hex[2..-1] if hex[0..1] == '0x'

  [value].pack('H*')
end