Skip to content

Instantly share code, notes, and snippets.

@AlexanderRD
Created October 18, 2017 09:02
Show Gist options
  • Save AlexanderRD/f1b73f5a913831923247c03d530d4e7c to your computer and use it in GitHub Desktop.
Save AlexanderRD/f1b73f5a913831923247c03d530d4e7c to your computer and use it in GitHub Desktop.
def bin_to_hex(s)
s.unpack('H*').first
end
def hex_to_bin(s)
s.scan(/../).map { |x| x.hex }.pack('c*')
end
#Kudos to: http://anthonylewis.com/2011/02/09/to-hex-and-back-with-ruby/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment