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
from array import array | |
from string import join | |
from struct import pack, unpack | |
_DECODE = lambda x, e: list(array('B', x.decode(e))) | |
_ENCODE = lambda x, e: join([chr(i) for i in x], '').encode(e) | |
HEX_TO_BYTES = lambda x: _DECODE(x, 'hex') | |
TXT_TO_BYTES = lambda x: HEX_TO_BYTES(x.encode('hex')) | |
BYTES_TO_HEX = lambda x: _ENCODE(x, 'hex') | |
BYTES_TO_TXT = lambda x: BYTES_TO_HEX(x).decode('hex') |