Skip to content
Advertisement

How to slice hex data?

I have and Hex data in which there are three data present on which I can separate the information contain in the hex data:

  1. ID (2 bytes)
  2. length of the packet(2 bytes)
  3. information

from the length of the packet, we come to know how long is the data in this hex data for example hex data = 0001001447364B5F48312E305F56312E312E3165000300133836333932313033343330343337310004000838303634000200154D414A3258584D524A32444A363135303900050005010006000843415244000700094341524431000800050000090018383939313035323138303935393533303834300D000A000E706F7274616C6E6D6D73

if we manually separate this HEX data according to the above information then we get this data 0001001447364B5F48312E305F56312E312E3165

here

id=0001

packet lenght=0014=20

information = 47364B5F48312E305F56312E312E3165

i have tried to separate the information by my code but it only separates the first data I want to separate the whole hex data

this is my python code:

JavaScript

can anyone help me to figure it up

Advertisement

Answer

You can loop over the data string and extract the data.

Here is how it would look like:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement