Fredrik said:
Tiziano Bettio wrote:
magic?
I suggest running my script on a couple of small text files. when you've done that,
see if you can figure out how the decompression algorithm works.
</F>
Tricky - especially checking the parity of the data bit, but I believe the
following works:
def decompress(filename):
m = '\x00\x00\x0fE\xc7\xc4'
m = [(ord(i) & 0x7F) - (ord(i) & 0x80) for i in m]
filename, data = open(filename, "rb").read(), filename[:-4]
class Unfold(object):
# Accumulator for partially unfolded data
args = []
try:
unfold = Unfold()
data = "==".join([data,'\n'])
compressed = [abs(data)]
for fold in compressed:
unfold.args.append(fold ** abs(fold))
except TypeError, unfold:
# No more unfolds
pass
decoder = __import__("".join(chr(ord(i)+j)
for i, j in zip(unfold.args[0], m))).decodestring
return decoder(data)
Michael