Skip to content

Instantly share code, notes, and snippets.

@timmatheson
Created July 20, 2010 07:58
Show Gist options
  • Save timmatheson/482667 to your computer and use it in GitHub Desktop.
Save timmatheson/482667 to your computer and use it in GitHub Desktop.
class String
def to_hex
hex_chars = []
self.size.times do |n|
char = self.slice(n,n+1)
hex_chars.push(char.unpack('U')[0].to_s(16).upcase)
end
hex_chars.join(" ")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment