Created
November 20, 2015 20:14
-
-
Save amckinley/4ab697f32a71493832e1 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 hex_to_bytearray(hex_str): | |
| array_len = ??? # how many bytes do you need for a hex string of length n? | |
| b_arr = bytearray(array_len) | |
| hex_to_decimal = { | |
| "00": 0, | |
| "01": 1, | |
| # etc. dont write this out; find a way to print out this table and then copy/paste it here | |
| } | |
| for idx, char_pair in enumerate(???): # how can you split the hex string into 2-character chunks? | |
| decimal_value = hex_to_decimal[char_pair] | |
| b_arr[idx] = decimal_value | |
| return b_arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment