Creating hash for folder

后端 未结 7 1154
梦谈多话
梦谈多话 2020-12-13 05:05

i need to create hash for folder, that contains some files. I already done this task for each of files, but i searching the way to create one hash for all files in folder.

7条回答
  •  无人及你
    2020-12-13 05:22

    Concatenate filenames and files content in one big string and hash that, or do the hashing in chunks for performance.

    Sure you need to take few things into account:

    • You need to sort files by name, so you don't get two different hashes in case files order changes.
    • Using this method you only take the filenames and content into account. if the filename doesn't count you may sort by content first then hash, if more attributes (ctime/mtime/hidden/archived..) matters, include them in the to-be-hashed string.

提交回复
热议问题