给定一个解压缩的 gzip 文件,有没有办法重新创建确切的原始 gzip 文件?
给定一个 gzip 文件 Z,如果我将其解压缩到 Z',有什么方法可以重新压缩它以获得完全相同相同的 gzip 文件 Z?粗略阅读 DEFLATE 格式后,我猜不会,因为任何给定文件都可能有 DEFLATE 流格式的多种表示形式,并且无法确定最初使用的是哪一个。任何人都可以确认这个推理是否正确,如果不正确,请指出我该怎么做?
为了加分,哪些压缩算法/格式被严格指定,以至于文件只有一种压缩表示形式?
谢谢!
Given a gzip file Z, if I decompress it to Z', is there any way I can recompress it to get the exact same gzip file Z back? After a cursory reading of the DEFLATE format, I am guessing no, as any given file may have multiple representations in DEFLATE stream format, and there is no way to determine which one was originally used. Can anybody confirm whether this reasoning is correct, and if not, point out how I can do this?
For bonus points, which compression algorithms/formats are tightly specified enough that there is only ever one compressed representation of a file?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 gzip 来说绝对不行,除非您也知道所涉及的工具和参数(甚至可能知道)。
考虑到所涉及的权衡,我不明白为什么这是可取的,因为用户无法平衡不同的关注点。我不想在网络服务器上使用相同的参数来动态执行 gzip 进行内容编码或传输编码,就像我在酒吧里高兴地让机器在一夜之间完成工作时压缩大量档案一样。
Definitely no for gzip, unless you also know the tools and parameters involved (and maybe even then).
Considering the trade-offs involved, I don't see why this would be desirable, as the user couldn't balance different concerns. I would not want to have the same parameters used to do gzip on the fly on a webserver for content-encoding or transfer-encoding as I would for zipping up a massive archive while I am happily in the pub letting the machine do its job overnight.