1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! # CRC32 V2
//!
//! This crate provides a simple CRC32 implementation in Rust.
//!
//! ## Usage
//!
//! To use this crate, add the following to your `Cargo.toml` file:
//!
//! ```toml
//! [dependencies]
//! crc32_v2 = "0.0.4"
//! ```
//!
//! Then, you can use the `crc32` or `crc32_little` functions to calculate the CRC32 checksum of a byte buffer.
//!
//! ## Example
//!
//! ```rust
//! use crc32_v2::byfour::crc32_little;
//! use crc32_v2::crc32;
//!
//! let crc = crc32(0, &[0u8, 1u8, 2u8, 3u8]);
//! assert_eq!(crc, 0x8BB98613);
//! let crc_little = crc32_little(crc, &[0u8, 1u8, 2u8, 3u8]);
//! assert_eq!(crc, 0x8BB98613);
//! ```
//!
//! ## Implementation Details
//!
//! The CRC32 algorithm is implemented using a standard polynomial and lookup tables for optimization.
//!
//! The `crc32` function takes two parameters:
//!
//! - `start_crc`: the initial CRC32 value (usually 0)
//! - `buf`: a slice containing the input bytes
//!
//! It returns a `u32`, which is the CRC32 checksum of the input buffer.
use crateCRC_TABLE;
/// This function calculates the CRC32 checksum of a byte buffer using a standard CRC32 algorithm.
///
/// # Arguments
/// * `start_crc` - the initial CRC32 value (usually 0)
/// * `buf` - a slice containing the input bytes
///
/// # Returns
/// (`u32`): the CRC32 checksum of the input buffer
///
/// # Examples
/// ```
/// use crc32_v2::crc32;
///
/// let crc = crc32(0, &[0u8, 1u8, 2u8, 3u8]);
/// assert_eq!(crc, 0x8BB98613);
/// ```