J
Jonas Galvez
Is there any built-in module that does this for me?
def hexlify(msg)
msg.split("").collect { |c| c[0].to_s(16) }.join
end
def unhexlify(msg)
msg.scan(/../).collect { |c| c.to_i(16).chr }.join
end
puts hexlify("In Ruby...")
puts unhexlify("496e20527562792e2e2e")
--Jonas Galvez
def hexlify(msg)
msg.split("").collect { |c| c[0].to_s(16) }.join
end
def unhexlify(msg)
msg.scan(/../).collect { |c| c.to_i(16).chr }.join
end
puts hexlify("In Ruby...")
puts unhexlify("496e20527562792e2e2e")
--Jonas Galvez