How to compare two tarball's content

后端 未结 11 844
北海茫月
北海茫月 2021-01-31 15:18

I want to tell whether two tarball files contain identical files, in terms of file name and file content, not including meta-data like date, user, group.

However, There

11条回答
  •  面向向阳花
    2021-01-31 16:12

    I propose gtarsum, that I have written in Go, which means it will be an autonomous executable (no Python or other execution environment needed).

    go get github.com/VonC/gtarsum
    

    It will read a tar file, and:

    • sort the list of files alphabetically,
    • compute a SHA256 for each file content,
    • concatenate those hashes into one giant string
    • compute the SHA256 of that string

    The result is a "global hash" for a tar file, based on the list of files and their content.

    It can compare multiple tar files, and return 0 if they are identical, 1 if they are not.

提交回复
热议问题