Bug: 180073849

Clone this repo:
  1. 2aff327 Update Android.bp by running cargo_embargo am: 7c019b1355 by James Farrell · 4 weeks ago main master
  2. 7c019b1 Update Android.bp by running cargo_embargo by James Farrell · 4 weeks ago
  3. ed0bce5 Update Android.bp by running cargo_embargo am: 80da21afa6 by James Farrell · 6 weeks ago
  4. 80da21a Update Android.bp by running cargo_embargo by James Farrell · 6 weeks ago
  5. d52e86d Migrate to cargo_embargo. am: 0cc164a9e5 am: 8afa3b35b0 am: fc296f8ebb by Andrew Walbran · 7 months ago android14-qpr3-release emu-34-2-dev android-14.0.0_r50 android-14.0.0_r51

crc32fast Build Status Crates.io Documentation

Fast, SIMD-accelerated CRC32 (IEEE) checksum computation


Simple usage

For simple use-cases, you can call the hash convenience function to directly compute the CRC32 checksum for a given byte slice:

let checksum = crc32fast::hash(b"foo bar baz");

Advanced usage

For use-cases that require more flexibility or performance, for example when processing large amounts of data, you can create and manipulate a Hasher:

use crc32fast::Hasher;

let mut hasher = Hasher::new();
hasher.update(b"foo bar baz");
let checksum = hasher.finalize();


This crate contains multiple CRC32 implementations:

  • A fast baseline implementation which processes up to 16 bytes per iteration
  • An optimized implementation for modern x86 using sse and pclmulqdq instructions
  • An optimized implementation for aarch64 using crc32 instructions

Calling the Hasher::new constructor at runtime will perform a feature detection to select the most optimal implementation for the current CPU feature set.

crc32fast (this crate)1.0.0baseline6831499
crc32fast (this crate)1.0.0pclmulqdq1407314

Memory Safety

Due to the use of SIMD intrinsics for the optimized implementations, this crate contains some amount of unsafe code.

In order to ensure memory safety, the relevant code has been fuzz tested using afl.rs with millions of iterations in both debug and release build settings. You can inspect the test setup in the fuzz sub-directory, which also has instructions on how to run the tests yourself.

On top of that, every commit is tested using an address sanitizer in CI to catch any out of bounds memory accesses.

Even though neither fuzzing nor sanitization has revealed any safety bugs yet, please don't hesitate to file an issue if you run into any crashes or other unexpected behaviour.

Available feature flags

std (default: enabled)

This library supports being built without the Rust std library, which is useful for low-level use-cases such as embedded where no operating system is available. To build the crate in a no_std context, disable the default std feature.

Note: Because runtime CPU feature detection requires OS support, the specialized SIMD implementations will be unavailable when the std feature is disabled.

nightly (default: disabled)

This feature flag enables unstable features that are only available on the nightly channel. Keep in mind that when enabling this feature flag, you might experience breaking changes when updating compiler versions.

Currently, enabling this feature flag will make the optimized aarch64 implementation available.


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.