I have a binary format specification. The specification lists tags/objects in hex notation like 0x1000
which in the actual file when read into bytes in python is the binary string b'\x00\x10'
.
There are 100s of tags and an existing mapping file is available that maps each "hex code" to a specific tag. Hence I want to be able to do a simple look-up to get the correct tag, eg. convert the 0x1000
to b'\x00\x10'
(one-time precomputed value that I can then simply compare to).
So how can I do this conversion?