Introducing HashTree


Welcome another entry to the projects page: HashTree!

What is it?

Hashtree is a pretty simple CLI utility to calculate hashes for everything in a directory tree and provide a single composite hash of everything, including subdirectories and their contents.

An example of it in use:

$ hashtree testing/happy_path
happy_path
┣━big.jpg: 062b949aaf95f87ee123183ddca6deb8
┣━empty.txt: d41d8cd98f00b204e9800998ecf8427e
┣━same contents different name: f11ea1768ecd409899c9402804f7a192
┣━上篇: f11ea1768ecd409899c9402804f7a192
┣━chain
┃ ┣━binary
┃  ┣━katie.jpg: ff1af431750190e13f6b63b1a1a4b17f
┃  ┗━Opal.jpg: 2eda526319e7facd6b941aeec80e5749
┃ ┗━text
┃   ┣━lorem_ipsum.txt: db89bb5ceab87f9c0fcc2ab36c189c2c
┃   ┗━this one has newlines: 1701734cd6b90895d166ce1dda4f4489
┣━empty
┗━humor
  ┗━bee movie.txt: 5c18b58b2e7194a7f78bb55671d43e10

Final hash: c2b54c4674e73d81b84ba643cb607e8d

It's a small program I wrote in python with a niche use case, but if you want to do that, it should work about as well, if not better, as anything else out there.

Why?

It's come in handy for me for the following things:

  • determine whether two directories on the same machine are the same without needing to buy or install tools like beyondcompare
  • determine whether two directories on different machines are the same without needing to send them over the network to compare them
  • automated backup deduplication
  • track changes to a file tree through time without needing to store every modification made to every file
  • prove that two different git operations (like rebase and squash) result in identical code

How do I get it?

Currently, the program's source is available on its github page, but that's the only way to get it.

Releases to pip and building binaries are planned for the future.