Skip to content

Instantly share code, notes, and snippets.

@secretfader
Created August 22, 2009 19:17
Show Gist options
  • Save secretfader/172947 to your computer and use it in GitHub Desktop.
Save secretfader/172947 to your computer and use it in GitHub Desktop.
Hexlify in Ruby
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