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

crc32c

Safe implementation for hardware accelerated CRC32C instructions with software fallback

13 releases

0.6.5 Feb 8, 2024
0.6.4 Jul 23, 2023
0.6.3 Apr 12, 2022
0.6.1 Jan 5, 2022
0.2.0 Nov 11, 2017

#36 in Algorithms

Download history 161732/week @ 2024-01-03 172877/week @ 2024-01-10 195675/week @ 2024-01-17 187472/week @ 2024-01-24 177400/week @ 2024-01-31 175671/week @ 2024-02-07 174904/week @ 2024-02-14 190664/week @ 2024-02-21 202946/week @ 2024-02-28 202084/week @ 2024-03-06 201716/week @ 2024-03-13 196797/week @ 2024-03-20 196502/week @ 2024-03-27 224640/week @ 2024-04-03 230384/week @ 2024-04-10 200127/week @ 2024-04-17

889,476 downloads per month
Used in 252 crates (47 directly)

Apache-2.0/MIT

28KB
579 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 nightly (enabled by default without feature)

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