# rust-crc32
Calculate CRC-32 checksum for binary data.
## How to install
```sh
cargo add crc32_light
```
## How to use
```rs
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:
```rs
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);
}
```