crc32_light 0.1.2

Calculate CRC-32 checksum
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented0 out of 10 items with examples
  • Size
  • Source code size: 19.03 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • kujirahand/rust-crc32
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kujirahand

rust-crc32

Calculate CRC-32 checksum for binary data.

How to install

cargo add crc32_light

How to use

use crc32_light::crc32;
fn main() {
    let crc = crc32(b"dog");
    println!("CRC32 = 0x{:08x}", crc);
}

Memo

It provides three methods for calculating CRC32:

  • crc32basic() — A simple and easy-to-understand implementation.
  • crc32() — An optimized version of crc32basic() designed to improve processing speed.
  • crc32speed() — A highly optimized implementation focused on maximum performance.

When processing data up to 100 KB, crc32 is the fastest. However, for data larger than 1 MB, all implementations reach the limitations of memory bandwidth, so the differences between algorithms become less noticeable.

Streaming API

You can calculate CRC32 in a streaming manner using the Crc32Stream struct:

use crc32_light::Crc32Stream;
fn main() {
    let mut stream = Crc32Stream::new();
    stream.update(b"hello ");
    stream.update(b"world");
    let crc = stream.finalize();
    println!("CRC32 = 0x{:08x}", crc);
}