Z63: a fast, 100% web-compliant text and binary compression/transfer system for PHP.

Bored this evening, I've not so much reinvented the wheel, as invented another way to use it.

%time php z63test.php /usr/share/dict/american-english
Normal length: 931467 bytes.
z63 length: 336720 bytes... 63% smaller!
Uncompressed length: 931467 bytes.
php z63test.php /usr/share/dict/american-english  0.28s user \
  0.02s system 99% cpu 0.304 total
Yes, you've seen that correct. It took less than .3 seconds on my 1Ghz laptop to compress almost 1MB of data down to about a third of it's size - into an XML compatible data format, then back into it's original form entirely in PHP!

The system cleanly degrades; if compression won't help, it won't force it. It will, however, continue to encode the string, so it's transferable via web-enabled applications.. You can even feed it binary data; it's even unicode clean (that's what it's primarily designed for, enabling binary data to be safely encapsulated, with less overhead than existing schemes.)

The result speaks for itself (Note that this data is rather worthless; it's just a free-form example):

Z63:
<?xml version="1.0" standalone="yes"?>
<FileData>
  <FileName>/usr/dict/words</FileName>
  <FileDate>2005-12-20T12:58:58-06:00</FileDate>
  <FileMD5>e954ccd9535d5550d8b632972b5a10ed</FileMD5>
  <FileBytes>931467</FileBytes>
</FileData>
<PassData>
  <Date>2007-11-26T07:26:57-06:00</Date>
  <MD5>03a43176887b657f90eab09e177c3a7d</MD5>
  <Bytes>336720</Bytes>
  <DataBlob>...</DataBlob>
</PassData>

Base64:
<?xml version="1.0" standalone="yes"?>
<FileData>
  <FileName>/usr/dict/words</FileName>
  <FileDate>2005-12-20T12:58:58-06:00</FileDate>
  <FileMD5>e954ccd9535d5550d8b632972b5a10ed</FileMD5>
  <FileBytes>931467</FileBytes>
</FileData>
<PassData>
  <Date>2007-11-26T07:27:36-06:00</Date>
  <MD5>bf1ecb99327ce7fb1f7496751039ea19</MD5>
  <Bytes>1241956</Bytes>
  <DataBlob>...</DataBlob>
</PassData>


Heck, it even compresses the front page of my website pretty well.
%time php z63test.php http://www.holwegner.com/
Normal length: 9911 bytes.
z63 length: 5077 bytes... 48% smaller!
Uncompressed length: 9911 bytes.
php z63test.php http://www.holwegner.com/  0.03s user \
  0.03s system 6% cpu 0.924 total