Return the binary data represented by the hexadecimal string. Every 2-digit hex representation is converted into the corresponding byte of data. The resulting byte string is therefore half as long as the hex string.
(hex_string, spaced=False)
| 13 | return hex_string |
| 14 | |
| 15 | def bytes_from_hex(hex_string, spaced=False): |
| 16 | """Return the binary data represented by the hexadecimal string. Every 2-digit hex representation |
| 17 | is converted into the corresponding byte of data. The resulting byte string is therefore half as long as the hex string. |
| 18 | """ |
| 19 | if spaced: |
| 20 | hex_string = ''.join(hex_string.split(' ')) |
| 21 | |
| 22 | byte_string = binascii.unhexlify(hex_string) |
| 23 | |
| 24 | return byte_string |
| 25 | |
| 26 | def shift_bytes(data, shift=1): |
| 27 | return data[-shift:] + data[:-shift] |