#crc32 #digest #crc32fast

crc32_digest

CRC32 implementation of digest::{Digest, DynDigest} using crc32fast

2 releases

0.8.1 Jun 4, 2019
0.8.0 Jun 4, 2019

#22 in #crc32

Download history 6/week @ 2024-07-20 8/week @ 2024-07-27 3/week @ 2024-09-07 3/week @ 2024-09-21 171/week @ 2024-09-28 235/week @ 2024-10-05 46/week @ 2024-10-12 134/week @ 2024-10-19 17/week @ 2024-10-26 528/week @ 2024-11-02

736 downloads per month
Used in 10 crates (via okstd)

MIT/Apache

23KB

crc32_digest

Build Status Crate API Minimum rustc version

An implementation of the digest crate's Digest and DynDigest traits using crc32fast.

If digest is built with the std feature enabled, Crc32 will implement Write as well.

Internally, the Crc32 struct provided by this crate implements the FixedOutput, Input, and Reset traits. A blanket impl of Digest and DynDigest is provided by digest for types implementing those traits (along with Clone and Default).

Requirements

Rust 1.32 or newer is required for u32::to_be_bytes.

Write support requires the std feature of digest to be enabled.

Usage

use crc32_digest::Crc32;
use digest::Digest;

fn main() {
    let mut crc32 = Crc32::new();
    crc32.input(b"hello, world");
    let result = crc32.result();
    
    // Get checksum as a byte slice
    assert_eq!(result.as_slice(), &[0xff, 0xab, 0x72, 0x3a]);
    // Format checksum as a lowercase hexadecimal string
    assert_eq!(format!("{:x}", result), "ffab723a");
}

Alternatively, Crc32::from_state(state: u32) can be used to create a new Crc32 instance with a specific initial state.

Dependencies

~420KB