views:

176

answers:

1

I was wondering if someone has come up with something similar to this??

a way to compress a text:

<?php
    $str = 'Hello world!';// the text here can be any characters long
    $key = compress($str);// should return a key 32characters long/ or a fixed number of characters
    $value = decompress($key);// should return "Hello World!"
?>

Using MD5 is a one way encryption/compression, basically I would like something like MD5 to be reversable. Not necessarly the MD5 it self.

+1  A: 

md5 is not a compression algorithm : it's a hashing algorithm.

If you want to compress/decompress, in PHP, you can use something like gzcompress, gzdeflate, bzcompress, ... depending on the compression algorithm you want to use, and the functions available on your server.

You can take a look at the Compression and Archive Extensions section of the manual, which lists the different extensions you might be able to use -- provided they're installed on your server.

Pascal MARTIN
But bear in mind that HTTP will negotiate and compress data on the fly if possible at both ends.
symcbean
I agree. Let something like php's ob_gzhandler or even better mod\_deflate handle the compression transparently if possible.
VolkerK