Is there any way I could save hexdump() to byte list so the list can be accessed by index. what I need is like this
byte = hexdump(packet)
for i in range(0, len(byte)):
print %x byte[i]
Is there any way I could save hexdump() to byte list so the list can be accessed by index. what I need is like this
byte = hexdump(packet)
for i in range(0, len(byte)):
print %x byte[i]
The byte content of the packet may be accessed by invoking str(packet)
, as follows:
content = str(packet) # decoded hex string, such as '\xde\xad\xbe\xef'
print content
for byte in content:
pass # do something with byte
EDIT - This answer specifies how this can be converted to a byte array, for example:
byte_array = map(ord, str(packet)) # list of numbers, such as [0xDE, 0xAD, 0xBE, 0xEF]
print byte_array
for byte in byte_array:
pass # do something with byte