#hashing #hardware-accelerated #crc #crc32 #simd #algorithm #sse

crc32c

Safe implementation for hardware accelerated CRC32C instructions with software fallback

16 releases

0.6.8 Jun 9, 2024
0.6.5 Feb 8, 2024
0.6.4 Jul 23, 2023
0.6.3 Apr 12, 2022
0.2.0 Nov 11, 2017

#20 in Algorithms

Download history 337362/week @ 2024-08-18 337271/week @ 2024-08-25 312963/week @ 2024-09-01 345047/week @ 2024-09-08 306517/week @ 2024-09-15 364033/week @ 2024-09-22 353744/week @ 2024-09-29 394629/week @ 2024-10-06 378778/week @ 2024-10-13 421308/week @ 2024-10-20 408149/week @ 2024-10-27 417184/week @ 2024-11-03 416260/week @ 2024-11-10 390068/week @ 2024-11-17 306240/week @ 2024-11-24 334782/week @ 2024-12-01

1,461,416 downloads per month
Used in 384 crates (67 directly)

Apache-2.0/MIT

28KB
584 lines

CRC32C

Crates.io Docs.rs Travis

Rust implementation of the CRC-32-Castagnoli algorithm with hardware acceleration where possible.

Hardware acceleration on the following architectures:

  1. x84-64 with SSE 4.2
    • All stable versions of Rust
    • If SSE 4.2 is enabled at compile time, it will only build the SSE implementation. Otherwise, the cpuid is used to find the best implementation at runtime.
  2. aarch64 with crc feature
    • Only available on rust version >= 1.80.0 or nightly

All other processors utilize a software fallback.

Usage

First, add this to your Cargo.toml:

[dependencies]
crc32c = "0.6"
extern crate crc32c;

fn main() {
    let message = b"Hello world!";
    let crc = crc32c::crc32c(message);

    println!("hash = {}", crc);
}

License

You may use this code under either the Apache 2.0 license or the MIT license, at your option.

No runtime deps