I have a file with binary data which I need to analyze. The data I am looking for is separated in two-byte long parts.
I tried using file.read(2), but this is very slow for a 1.5 MB file.
file = open('data', 'rb')
data = file.read().hex()
is what I currently use to load the data in a b''
object and convert it to hex data for further processing.
Now I need to read always two bytes from this string, how can I achieve this?
F.e.:
...c429c429c429c429...
should be processed as
c429, c429, c429, c429
Where 'c4' equals 1 bytes.