#crc32 #checksum #crc #simd #nvme

crc32fast-lib

Fast, SIMD-accelerated CRC-32/ISO-HDLC (aka 'crc32') checksum computation in Rust exposed as a C-compatible shared library

2 stable releases

1.0.1 Dec 28, 2024
1.0.0 Dec 27, 2024

#1139 in Algorithms

Download history 222/week @ 2024-12-24 2/week @ 2024-12-31 2/week @ 2025-01-07

226 downloads per month

MIT license

9KB
98 lines

crc32fast-lib

Tests Latest Version Documentation

Fast, SIMD-accelerated CRC-32/ISO-HDLC (aka crc32) checksum computation in Rust exposed as a C-compatible shared library.

Results in a dramatic performance improvement. For example, when using it via FFI in PHP, it's >10X faster than PHP's native crc32 implementation.

Changes

See the change log.

Usage

cargo build will produce a shared library target (.so on Linx, .dll on Windows, .dylib on macOS, etc) and a C header file.

Use the header file and library as you would normally when using a shared library in your language of choice.

PHP example

/** \FFI $ffi */

$hasher = $ffi->hasher_new();
$ffi->hasher_write($hasher, 'hello world!', 12);
$checksum = $ffi->hasher_finalize($hasher); // 0x03b4c26d

References

  • crc32fast - The underlying Rust library which implemented this SIMD-accelerated approach.
  • crc-fast-php - An implementation of this library in PHP using FFI.
  • crc64fast-nvme - A similar project which computes CRC-64/NVME checksums at >20GiB/s, also with a C-compatible shared library.

Dependencies

~0–1.5MB
~21K SLoC