Supercomputer and encryption and compression @ rate of 96%

Michael Spencer mahs at telcopartners.com
Thu Apr 14 18:25:58 EDT 2005


Fredrik Lundh wrote:
> Tiziano Bettio wrote:
> 
> 
>>could someone please tell me that this thread wasn't a aprilsfoll day
>>joke and it is for real...
>>
>>i'm pretty much able to go down to a single bit but what would be the
>>reverse algorithm as stated by martin...
> 
> 
> 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




More information about the Python-list mailing list