Given a decompressed gzip file, is there any way to recreate the exact original gzip file?
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 representa开发者_如何转开发tion of a file?
Thanks!
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.
精彩评论