Skip to content

Instantly share code, notes, and snippets.

@upidea
Created April 16, 2019 08:18
Show Gist options
  • Select an option

  • Save upidea/71043acfd1474319e6bdf1474167bf7a to your computer and use it in GitHub Desktop.

Select an option

Save upidea/71043acfd1474319e6bdf1474167bf7a to your computer and use it in GitHub Desktop.
import mmap
import struct
print(struct.unpack('<i', b'\xa0\xcf\x6e\x44')) # 1148112800
struct.unpack('>i', b'\x95\x6b\x31\x93') # -1788137069
with open('tmp', 'rb', 0) as file, \
mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as s:
pos = s.find(b'\x64\x65')
if pos != -1:
x=struct.unpack('cc', s[pos+2:pos+4])
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment