Skip to content

Instantly share code, notes, and snippets.

@levicole
Forked from secretfader/hexlify_ruby.rb
Created August 22, 2009 22:43
Show Gist options
  • Save levicole/173018 to your computer and use it in GitHub Desktop.
Save levicole/173018 to your computer and use it in GitHub Desktop.
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("Hello World")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment