Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Make from/to text DEADFACE raw data DEADFACE
- #
- # 1st way
- #
- import struct
- # 1
- hex_str = "DEADFACE"
- # create int
- a = int(hex_str, 16)
- b = st.pack("L", a)
- # b == '\xce\xfa\xad\xde\x00\x00\x00\x00'
- # 2nd way
- #
- import binascii as b2a
- hex_str = "DEADFACE"
- res = b2a.unhexlify(hex_str)
- # res =='\xde\xad\xfa\xce'
- # 3rd way
- import binascii as b2a
- a = 8037
- b = hex(a)
- # b == '\x1F65'
- b = b[2:].replace("L", "")
- # b == '1F65'
- res = b2a.unhexlify(b)
- # res =='\x1f\x65'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement