2016-02-26 22:57
浏览 134


I know that I can compress using PHP

gzcompress($contents, 9);

But I don't like the results. Even with last version of zlib I get bigger file that output of the 7zip(deflate, of course).

So how to replace gzip headers with zlib headers (with ADLER32 checksum)

图片转代码服务由CSDN问答提供 功能建议


  gzcompress(  $ contents,9); 

但我不喜欢结果。 即使使用最新版本的zlib,我也会得到更大的文件,即输出7zip(当然是deflate)。


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douqianmin5367 2016-02-27 15:46

    Your question is not clear, but I think you're asking how to take the gzip output of 7zip and convert it to zlib.

    You would need to decode the gzip header and strip it off. (It is likely 10 bytes, but it could be longer if it has a file name in it.) RFC 1952 describes the header format. Then you would prepend a two-byte zlib header, e.g. 0x78 0xda.

    Then strip the last eight bytes from the end and append a four-byte Adler-32 sum of the uncompressed data in big-endian order. You will need to compute that yourself, where it is described in RFC 1950, or you can adapt the zlib implementation.

    点赞 打赏 评论

相关推荐 更多相似问题