paq
Hash file or directory recursively.
Powered by blake3
cryptographic hashing algorithm.
Usage
Install the command line interface executable or use the crate library.
Included in this repository is an example directory containing some sample files, a subdirectory and a symlink to test paq
functionality.
Executable
Installation requires cargo.
Run cargo install paq
.
Invoke Command
Run paq [src]
to hash source file or directory.
For help, run paq --help
.
Hash Example Directory
paq ./example
Path to example directory can be relative or absolute.
Expect different results if -i
or --ignore-hidden
flag argument is used.
Crate Library
Add paq
to project dependencies in Cargo.toml
.
Use Library
use paq;
let source = from;
let ignore_hidden = true; // .dir or .file
let source_hash: ArrayString = hash_source;
println!;
Hash Example Directory
use paq;
let source = from;
let ignore_hidden = true;
let source_hash: ArrayString = hash_source;
assert_eq!;
Expect different results if ignore_hidden
is set to false
.
Content Limitations
Hashes are generated using file system content as input data to the blake3
hashing algorithm.
By design, paq
does NOT include file system metadata in hash input such as:
- File modes
- File ownership
- File modification and access times
- File ACLs and extended attributes
- Hard links
- Symlink target contents
Additionally, files or directory contents starting with dot or full stop can optionally be ignored.
How it Works
- Recursively get path(s) for a given source argument.
- Hash each path and file content if path is for a file.
- Sort the list of hashes to maintain consistent ordering.
- Compute the final hash by hashing the sorted list of hashes.