Skip to content

Instantly share code, notes, and snippets.

@bewest
Forked from n-west/gist:3857129
Created October 9, 2012 07:13
Show Gist options
  • Save bewest/3857132 to your computer and use it in GitHub Desktop.
Save bewest/3857132 to your computer and use it in GitHub Desktop.
decode chunk modifications
def decode_chunk(chunk):
"""
Experiment: decode a chunk!
<snip>
"""
# give ourselves a copy of this record as a bytearray to sanitize things a bit.
record = bytearray(chunk)
if chunk == 0x1f:
try:
print hex(record)
except:
pass
else:
record.extend(chunk)
def do_chunk(handle):
"""read a chunk, and call decode_chunk"""
chunk = read_chunk(handle)
decode_chunk(chunk[3]) # --chunk 4, so we only read every 4th byte (the rest are NULLs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment