module Cryptools::Converters

Public Instance Methods

bytes2hex(bytes) click to toggle source
# File lib/cryptools.rb, line 22
def bytes2hex(bytes)
  bytes.map{|b| b.to_s(16)}.join
end
hex2bytes(hexStr) click to toggle source
# File lib/cryptools.rb, line 18
def hex2bytes(hexStr)
  hex2str(hexStr).unpack('C*')
end
hex2str(hexStr) click to toggle source
# File lib/cryptools.rb, line 10
def hex2str(hexStr)
  [hexStr].pack('H*')
end
str2bytes(str) click to toggle source
# File lib/cryptools.rb, line 26
def str2bytes(str)
  str.split('').map!{|c| c.ord}
end
str2hex(str) click to toggle source
# File lib/cryptools.rb, line 14
def str2hex(str)
  str.unpack('H*').first
end