binAry

Author Avatar
Aryb1n 4月 21, 2017

p32 u32

>>> import struct
>>> p32(0xdeadbeef) == struct.pack('I', 0xdeadbeef)
True
>>> u32('abcd') == struct.unpack('I', 'abcd')[0]
True
>>> '37130000'.decode('hex') == '\x37\x13\x00\x00'
True
>>> u8('\x41') == 0x41
True
>>> u8('A') == 0x41
True

Notice:

u32('abcd') => u32('\x61\x62\x63\x64')
'A' => '\x41' => String
0x41 => number

struct.unpack => http://blog.csdn.net/gracioushe/article/details/5915900
struct => https://docs.python.org/2/library/struct.html