crc32-v2 0.0.2

A port of the CRC-32 algorithm to Rust
docs.rs failed to build crc32-v2-0.0.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: crc32-v2-0.0.5

CRC32

Resurrecting the crc32 crate from the ashes.

Usage

Add crc32-v2 to your Cargo.toml file:

[dependencies]
crc32-v2 = "0.0.2"

or run:

cargo add crc32-v2

Examples

use crc32_v2::crc32;
use crc32_v2::byfour::{crc32_little, dolit32};

const CRC32_INIT: u32 = 0; // Initial CRC value, you can customize it

fn main() {
    // Your data to calculate CRC for
    let data = b"Hello, world!";

    // Calculate CRC
    let result_crc = crc32(CRC32_INIT, data);

    // Print the result
    println!("CRC-32: {:x}", result_crc);

    // Calculate CRC using the little-endian method
    let result_crc_little = crc32_little(CRC32_INIT, data);

    // Print the result
    println!("CRC-32 (Little Endian): {:x}", result_crc_little);

    // Example for using dolit32
    let buf4: [u32; 8] = [0, 1, 2, 3, 4, 5, 6, 7];
    let mut c = CRC32_INIT;
    let mut buf4pos = 0;
    dolit32(&mut c, &buf4, &mut buf4pos);

    // Print the result
    println!("CRC-32 after dolit32: {:x}", c);
}

Warning The dolit4 and dolit32 functions modify the input c and buf4pos in place, so you should be careful when reusing these variables for subsequent CRC calculations.