Skip to content
payden edited this page Feb 26, 2013 · 1 revision

Examples

Here's a quick example proving php-xz works as advertised:

compress.php

<?php
$fh = fopen("php://stdin", "r");
$xz = xzopen("php://stdout", "w");
while (!feof($fh)) {
  xzwrite($xz, fread($fh, 1024));
}
fclose($fh);
xzclose($xz);
?>

decompress.php

<?php
$xz = xzopen("php://stdin", "r");
$fh = fopen("php://stdout", "w");
while (!feof($xz)) {
  fwrite($fh, xzread($xz, 1024));
}
xzclose($xz);
fclose($fh);
?>

Shell Fun

payden@obfuskate:~$ du -h -s php-5.4.12/
175M    php-5.4.12/
payden@obfuskate:~$ tar -cf - php-5.4.12 | php compress.php > php-5.4.12.tar.xz
payden@obfuskate:~$ tar -cf - php-5.4.12 | xz -z - > php-5.4.12-xz.tar.xz
payden@obfuskate:~$ sha1sum php-5.4.12.tar.xz
986114b3d7aa1979f782176c1a36b112dca5ca72  php-5.4.12.tar.xz
payden@obfuskate:~$ sha1sum php-5.4.12-xz.tar.xz
986114b3d7aa1979f782176c1a36b112dca5ca72  php-5.4.12-xz.tar.xz
payden@obfuskate:~$ rm -rf php-5.4.12
payden@obfuskate:~$ cat php-5.4.12.tar.xz | php decompress.php | tar -xf -
payden@obfuskate:~$ du -h -s php-5.4.12
175M    php-5.4.12
payden@obfuskate:~$ 
Clone this wiki locally