Why do the md5 hashes of two tarballs of the same file differ?

前端 未结 2 1302
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 08:00

I can run:

echo \"asdf\" > testfile
tar czf a.tar.gz testfile
tar czf b.tar.gz testfile
md5sum *.tar.gz

and it turns out that a.ta

2条回答
  •  情话喂你
    2020-12-30 08:34

    For MacOS:

    In man tar we can look at --options section and there we will find !timestamp option, which will exclude timestamp from our gzip archive. Usage:

    tar --options '!timestamp' -cvzf archive.tgz filename
    

    It will produce same md5 sum for same files with same names

提交回复
热议问题