Created
October 18, 2017 09:02
-
-
Save AlexanderRD/f1b73f5a913831923247c03d530d4e7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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