#crc32 #checksum #const #crc #build-time

const-crc32

A const fn implementation of crc32 checksum algorithm

6 releases (stable)

1.3.0 Sep 6, 2023
1.3.0-rc.1 Jun 23, 2023
1.2.0 Nov 2, 2022
1.1.0 Oct 5, 2022
1.0.1 Oct 5, 2022

#249 in Algorithms

Download history 608/week @ 2023-12-13 297/week @ 2023-12-20 274/week @ 2023-12-27 545/week @ 2024-01-03 607/week @ 2024-01-10 803/week @ 2024-01-17 889/week @ 2024-01-24 1286/week @ 2024-01-31 900/week @ 2024-02-07 904/week @ 2024-02-14 947/week @ 2024-02-21 895/week @ 2024-02-28 793/week @ 2024-03-06 1122/week @ 2024-03-13 1516/week @ 2024-03-20 1152/week @ 2024-03-27

4,732 downloads per month
Used in 10 crates (via frost-core)

MIT license

8KB
99 lines

const-crc32

A const fn crc32 checksum implementation.

Examples

const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
const CKSUM: u32 = const_crc32::crc32(BYTES);
assert_eq!(CKSUM, 0x414fa339_u32);

Usage

This is a naive implementation that should be expected to have poor performance if used on dynamic data at runtime. Usage should generally be restricted to declaring const variables based on static or const data available at build time.

#[const_eval_limit]

You may need to increase the crate-wide const_eval_limit setting to use const_crc32 for larger byte slices.

Increating const_eval_limit requires the nightly-only #![feature(const_eval_limit)].

Previously, this crate set the limit itself, however, as of the 2022-10-30 nightly, the value set in const_crc32 does not increase the limit for crates which use the library.

Compile time for const data around 100k is less than 1s.


lib.rs:

A const fn crc32 checksum implementation.

Examples

const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
const CKSUM: u32 = const_crc32::crc32(BYTES);
assert_eq!(CKSUM, 0x414fa339_u32);

No runtime deps