module Base16

Constants

VERSION

Public Instance Methods

decode16(what) click to toggle source
# File lib/base16.rb, line 6
def decode16(what)
  chars = ''
  ret = ''
  what.each_char do |c|
    chars += c
    if chars.size == 2
      ret += chars.to_i(16).chr
      chars = ''
    end
  end
  ret
end
encode16(what) click to toggle source
# File lib/base16.rb, line 19
def encode16(what)
  ret = ''
  what.each_char do |c|
    ch = c.ord.to_s(16)
    if ch.size == 1
      ch = '0' + ch
    end
    ret += ch
  end
  ret.upcase
end