I have a file with line like this : \x04\x01\x00\x00\x00\x00\x00{ and I want to parse it like this : 04:01:00:00:00:00:00:7b, where { must be converted in hex ({ = 7b).
I'm trying to build a little python script, but the tricky part of converting some (not all) characters into hex is hard for me.
Here is my beginnig method:
def hex_parser(line):
result = ''
for l in line:
if len(result):
result = result + ':'
if l != '\\' or l != ',' or l != '\n':
tmp_l = l.encode('utf8').hex()
if len(tmp_l) == 1:
tmp_l = '0' + tmp_l
result = result + tmp_l
return result
Thanks for help.