I have a file which contains in each line a set of bytes for example:
4655d16c690f2789c2d3e803e388637f
16161b1504137217336d403e2a03c669
fa79c5ffe35d112915f0f3243fc68fb4
87d57d0a63e52b6df869eb5c0aac4328
640c2eefb7829d863f7aa686bc513acc
4024767c463558b7c7cd0ffd4f0aaa6d
18ee0b17f5b5206df0443e658b105990
7b40bf42d2cfc290eed4c4edcb9d3e91
b57dad9833c3e174e05a5ae75cac70ed
I want to convert line in an array,then convert byte in decimal, for example:
4655d16c690f2789c2d3e803e388637f
The result is:
46 55 d1 6c 69 0f 27 89 c2 d3 e8 03 e3 88 63 7f
Then convert each byte in decimal:
[70,85,209,108,105,15,39,137,194,211,232,3,136,227,99,127]
I try by using this code ,
with open(Srcpath, 'r') as f:
with open(Destpath, 'w') as fp:
for key in f:
key_Separated=[key[i:i+2] for i in range(0, len(key), 2)]
rejoined = ' '.join(key_Separated)
Decimal= [i for i, b in enumerate(rejoined ) if b=='1']
print(Decimal)
fp.write(str(Decimal))
so it gives this wrong results:
[43]
[21, 45]
[27, 42]
[13, 31, 37, 42]
[16, 21, 28]
[13, 36]
[12, 43, 46]
[0, 6, 18, 27, 37]
How could I correct them please?