在PHP和JS中压缩和解压缩

时间:2010-01-29 16:55:29

标签: php encryption compression

我想知道是否有人想出类似的东西?

压缩文本的方法:

<?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!"
?>

使用MD5是单向加密/压缩, 基本上我想像MD5这样可以反转。 MD5本身并非必要。

1 个答案:

答案 0 :(得分:2)

md5不是压缩算法:它是hashing算法。

如果要压缩/解压缩,在PHP中,您可以使用gzcompressgzdeflatebzcompress等内容,具体取决于您要使用的压缩算法,以及服务器上可用的功能。

您可以查看本手册的Compression and Archive Extensions部分,其中列出了您可以使用的不同扩展程序 - 前提是它们已安装在您的服务器上。