Last active
July 2, 2019 12:56
-
-
Save nmarley/33ef02f2a674d5ac1dac to your computer and use it in GitHub Desktop.
Ruby reverse bytes in hex string (endianness)
This file contains 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
# Ruby reverse bytes in hex string (endianness) | |
def flip_bytes(hex) | |
return hex.scan(/../).reverse.join('') | |
end | |
hs = "e0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7" | |
puts flip_bytes(hs) | |
# => "c762a6567f3cc092f0684bb62b7e00a84890b990f07cc71a6bb58d64b98e02e0" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment