Created
August 6, 2011 14:31
-
-
Save 3en/1129386 to your computer and use it in GitHub Desktop.
Convert array of hex decimal representation (ObjectId.data) to a hex string
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
# Converts an array of hex decimal representation (ObjectId.data) to a hex string. | |
# e.g [78, 26, 131, 172, 159, 165, 6, 0, 1, 0, 0, 125] > '4e1a83ac9fa506000100007d' | |
# convert_to_hex_string([78, 26, 131, 172, 159, 165, 6, 0, 1, 0, 0, 125]) | |
def convert_to_hex_string(dec_array) | |
dec_array.map { |n| "%02x" % n }.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment