https://github.com/fcivaner/hashdir
A command line tool to calculate hashes of directory trees using various hash algorithms.
https://github.com/fcivaner/hashdir
cli directories hash imohash
Last synced: 8 months ago
JSON representation
A command line tool to calculate hashes of directory trees using various hash algorithms.
- Host: GitHub
- URL: https://github.com/fcivaner/hashdir
- Owner: fcivaner
- License: mit
- Created: 2020-06-20T20:14:05.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-11T17:48:17.000Z (about 1 year ago)
- Last Synced: 2024-07-18T23:36:43.335Z (12 months ago)
- Topics: cli, directories, hash, imohash
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hashdir
A command line tool to calculate hash of directory trees using various hash algorithms.
## Installing
To install, run the following command in your terminal:
```pip3 install hashdir```
## Installing on Android
You may want to install hashdir through Termux or similar on android to check hashes of directories on your android system.
On some systems, you may have to reinstall python to get development libraries, and install libcrypt before installing hashdir for the installation to work:
```bash
apt install python
apt install libcrypt
```Otherwise, installation on android is the same as others.
```pip3 install hashdir```
## Usage
```text
usage: hashdir [-h] [-a {md5,sha1,imohash}] [--log-level {error,info,debug}]
[-v]
[directory]A command line tool to calculate hashes of directory trees using various hash
algorithms.positional arguments:
directoryoptions:
-h, --help show this help message and exit
-a {md5,sha1,imohash}, --algorithm {md5,sha1,imohash}
warning: imohash is a constant-time hashing library,
and while being fast for large files, it produces
approximate results.
--exclude EXCLUDE exclude a pattern, like .git/* or *.log
--log-level {error,info,debug}
-q, --quiet only output the final hash value.
-v, --version show program's version number and exit
```## Algorithm
Hashdir performs the following steps;
- Walk the directory tree and find all file paths.
- Sort file paths to get a consistent hash for every system.
- Compute the hash value for each file separately using the algorithm selected by the -a option (Or md5 as default).
- Create a "hash string" using the results. Hash string is a string value which consists of a file path and its hash separated by a space character on each line. Print the hash string.
- Compute the md5 hash value of the hash string, and print it as the result.## Contributing
Contributions are welcome! Please use black for formatting code before sending a PR.