crc-rs
A no_std Rust library for computing CRC checksums of every common width with standard and custom algorithms.
Repository Health
Technical Analysis
crc is a lightweight, dependency-minimal Rust crate for computing cyclic redundancy check (CRC) values across all common widths: CRC-8, CRC-16, CRC-32, CRC-64, and CRC-128. It ships the full CRC catalog of well-known standards (such as CRC_16_IBM_SDLC and CRC_32_ISCSI) while also letting you define your own algorithm by specifying the polynomial, init, refin/refout, xorout, and residue parameters.
Built as no_std with #![forbid(unsafe_code)], crc runs everywhere from embedded firmware to server code. It exposes pluggable implementations that trade binary size for throughput, so you can pick a table-free variant to minimize footprint or a 16-lane slice-by-16 table to maximize speed, all through the same const-evaluable API.
What You Get
- Support for CRC-8, CRC-16, CRC-32, CRC-64, and CRC-128 widths through a single generic API
- A bundled catalog of well-known CRC standards plus the ability to define fully custom algorithms
- Pluggable implementations (NoTable, Table<1>, Table<16>) that trade binary size against throughput
- A
no_std,forbid(unsafe_code)design suitable for embedded and constrained targets - A one-shot
checksummethod and an incrementalDigestfor streaming updates
Common Use Cases
- Verifying data integrity of files, network frames, or storage blocks
- Implementing wire protocols that mandate a specific CRC standard (e.g. X.25, iSCSI)
- Computing checksums in embedded or
no_stdenvironments where allocation is unavailable - Generating a compile-time checksum constant for known static data
Under The Hood
Architecture - The crate centers on two generic types in src/lib.rs: Crc<W, I> holding a &'static Algorithm<W> plus precomputed table Data, and Digest<'a, W, I> for incremental hashing. Width-specific impl blocks in crc8.rs, crc16.rs, crc32.rs, crc64.rs, and crc128.rs provide new, checksum, digest, and update, all delegating to shared const helpers in util.rs (bitwise CRC step per width) and table.rs (lookup-table generation). An Implementation trait with a sealed Table<const L> type parameter selects between no-table, single-lane, and 16-lane slice-by-16 strategies at the type level.
Tech Stack - Pure Rust, edition 2021, MSRV 1.83. The only runtime dependency is crc-catalog (2.4.0), which supplies the Algorithm struct and the named-standard constants re-exported from the crate root. The crate is #![no_std] and #![forbid(unsafe_code)], with a Criterion-style bench harness under benches/ and CI via GitHub Actions.
Code Quality - Code is clean, small, and idiomatic, using const generics to encode implementation choice without runtime branching. Correctness is covered by an integration test suite in tests/crc.rs plus an inline test_clone unit test, and every algorithm carries a self-check value validated against the reference check constant. The forbid(unsafe_code) attribute and const-fn discipline keep the surface auditable.
API Design - The public API is compact and ergonomic: pick a standard constant, call Crc::<uN>::new(&ALG), then checksum(bytes) or build a Digest for streaming update/finalize. Documentation includes runnable doctests for both standard and custom algorithms, and the implementation choice is opt-in via a type parameter so beginners get a sensible default while advanced users tune size/speed.
Used by 3 apps in this directory
hoodik
File Storage · Security
Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support
Qdrant
Databases · AI Development · Search
Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.
Svix
Developer Tools · Automation
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.