Advertisement
dan-masek

Untitled

Jul 30th, 2017
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import lz4.block
  2. import struct
  3.  
  4. INPUT_FILE_NAME = 'Hammer.lua'
  5. OUTPUT_FILE_NAME = 'Hammer.out.lua'
  6.  
  7. with open(INPUT_FILE_NAME, 'rb') as f:
  8.     data = f.read()
  9.  
  10. header = data[:16]
  11. payload = data[16:]
  12.  
  13. magic, outsize = struct.unpack('4sl8x', header)
  14.  
  15. if (magic != 'LZ4 '):
  16.     print "Invalid format"
  17.     exit(1)
  18.  
  19. if (outsize <= 0):
  20.     print "Invalid ousize"
  21.     exit(1)
  22.  
  23. unpacked = lz4.block.decompress(payload, outsize)
  24.  
  25. with open(OUTPUT_FILE_NAME, 'wb') as f:
  26.     f.write(unpacked)
  27.     print "Wrote %d bytes to file %s." % (outsize, OUTPUT_FILE_NAME)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement