crc-rs

A no_std Rust library for computing CRC checksums of every common width with standard and custom algorithms.

Library
Cargo
v3.4.0
233stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
39/100Needs Attention
Development Activity4
Maintenance0
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture85
Code Quality88
Innovation82
Learning Curve80

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 checksum method and an incremental Digest for 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_std environments 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search