| Crates.io | hash-crate |
| lib.rs | hash-crate |
| version | 0.0.9 |
| created_at | 2026-01-02 21:04:45.770526+00 |
| updated_at | 2026-01-04 00:44:15.644918+00 |
| description | utility for generating deterministic hashes of local crates |
| homepage | |
| repository | https://github.com/joseph-gio/hash-crate |
| max_upload_size | |
| id | 2019194 |
| size | 53,751 |
hash-crate is a fast, deterministic hashing tool for Rust crates and their transitive dependencies.
It is designed for CI environments and large workspaces where you want to:
Cache prebuilt binaries for local crates
Detect when a crate actually needs to be rebuilt
Avoid over-invalidating caches due to unrelated changes in a workspace
Scale to hundreds or thousands of dependencies
The output hash is intended to be stable across machines and independent of filesystem layout.
Cargo does not provide a built-in way to compute a content-based hash for a single crate in a workspace, considering only the dependencies it actually uses.
hash-crate solves this by:
Resolving the per-crate transitive dependency graph
Hashing the contents of all path dependencies
Including version/source information for non-path dependencies
Producing a single deterministic hash suitable for cache keys
This makes it ideal for:
Large monorepos
xtask-style tooling (without needing cargo xtask)
Features
Very fast (uses Rayon + BLAKE3)
Deterministic (order-independent, thread-safe)
Per-crate granularity
Handles:
Path dependencies
Workspace members
[patch] overrides
Deduplicated dependencies
cargo binstall hash-crate
hash-crate <package-name>
Example:
hash-crate xtask-build
Output:
9e8b7a4b1d9c4b6b3f8c6c1a1a4e0d9e7c9a5f0c2c0c3a7e8c6b9e1f4d2
This hash represents:
The target crate
All of its transitive dependencies
The contents of any path dependencies
The hash will change if any of the following change:
Files inside a path dependency
Dependency versions
Git revisions
Dependency graph structure
Cargo patch overrides
The hash should not depend on:
Absolute filesystem paths
Dependency resolution order
Thread scheduling
Host machine
Typical pattern:
Compute the hash:
HASH=$(hash-crate xtask-build)
Use it as an artifact key:
# for some local crate called `xtask-build`
xtask-build-${HASH}-${RUNNER_TYPE}.tar.gz
If the artifact exists:
Otherwise:
Build the crate
Upload the artifact
Invalidation is automatic.
hash-crate is optimized for large workspaces:
Parallel directory hashing using Rayon and BLAKE3
Streaming dependency resolution
Deterministic folding of results
On large applications (1000+ dependencies), runtime is typically dominated by cargo metadata generation.
Replacing Cargo’s dependency resolver
Being human-readable
Supporting partial or heuristic hashing
This tool is intentionally strict and conservative.
MIT OR Apache-2.0
This README was originally written using AI. The crate was not.