Zlib7
From Idiki
Contents |
The idea
Zlib7 compresses a file of X size to the specified Y size, that cannot be greater than 28 bytes. That's all.
The idea is simple: we keep only an hash of the data we want to compress (in this case the SHA1 digest is used), then, when we need to decompress it, we generate random data of the same size of the compressed one, and we hash it. If the hash matches, we've decompressed it ;) Otherwise we generate another block of random data and try the hash again.
Surely the zlib7's compression requires A LOT of cpu power, but it is mainly designed for the year 2500, after the Fourth World War, when the quantum computer will be the standard.
But what if the user wants to compress the data to a specified size? Well, it's possible. We just keep some bytes in the saved compressed file, the rest is the hash of the discarded ones.
Examples
Usage: zlib7 cX|d filein fileout
cX to compress filein keeping `X' bytes of the input data.
The size of fileout will be 28 bytes + `X' bytes.
d to decompress filein to fileout
Examples:
echo h > filein
./zlib7 c filein fileout
./zlib7 d fileout decompressed
diff filein decompressed
Notes
If you didn't already get it this is just a "fun to code" idea, in fact, the only implementation has been written for the IOCCC.
Benefits
No need of Hard Disks greater than 2 Mb.
See Also
You can find the implementation of this idea here: zlib7
Categories: Implemented ideas | Compression | SHA | Hash | Algorithm
