doushou8299 2016-02-26 22:57
浏览 189
已采纳

用zlib头替换压缩文件的gzip头

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)

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效