开发者

Compressing and Decompress in PHP and JS

开发者 https://www.devze.com 2022-12-18 07:05 出处:网络
I was wondering if someone has come up with something similar to this?? a way to compress a text: <?php

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 n开发者_开发百科umber 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消