Home > Software engineering >  similar bytes in hex values [python]
similar bytes in hex values [python]

Time:02-10

I have a folder with multiple binary files.

  1. read binary files in the folder
  2. convert it to hex values

example: a8cbef7ce50c028a8d773d324a0c7cb5 = 305c72a71b6dfbfc050000005d000000d98c0e4e00000000

Here's the output using binascii.hexlify:

b'01 00 00 00 00 00 00 00 D0 F4 0A 00 00 00 00 00 06 00 00 00 70 1B 00 00'

b'30 5C 72 A7 1B 6D FB FC 05 00 00 00 59 00 00 00 5A F9 06 CC 00 00 00 00'

b'30 5C 72 A7 1B 6D FB FC 05 00 00 00 5D 00 00 00 D9 8C 0E 4E 00 00 00 00'

b'D3 45 C5 99 15 F8 DE 68 C2 F9 91 C7 81 FA FC 90 8A A2 AD B3 68 34 03 9C'

b'D3 45 C5 99 15 F8 DE 68 C2 F9 91 C7 81 FA FC 90 8A A2 AD B3 68 34 03 9C'

I'm stuck on how to compare these hex values, find similar bytes and patterns, and would like to have an output of "these are the similar bytes: "

for example, row 2 and 3 have similar patterns: 30 5C 72 A7 1B 6D FB FC 05 00 00 00 row 3 and row 4 have same values.

How do we compare these values to have an output of similar bytes?

How to compare it one at a time, row by row

Thank you

CodePudding user response:

  •  Tags:  
  • Related