mycrc 0.3.1

Create your own cyclic redundancy check (CRC).
Documentation
  • Coverage
  • 41.18%
    7 out of 17 items documented1 out of 1 items with examples
  • Size
  • Source code size: 34.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.48 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kurotakazuki/mycrc
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kurotakazuki

My CRC

Crate API

Create your own cyclic redundancy check (CRC).

Getting Started

  1. Create your own CRC using [CRC::new].
  2. Create checksum from message.
    • [CRC::checksum]
    • [CRC::initialize] -> [CRC::calc_bytes] -> ... -> [CRC::calc_bytes] -> [CRC::finalize]
  3. Use [CRC::is_error_free_bytes] to check if bytes [message + checksum] are error-free.

Example

use mycrc::{CRC, Endian};

// message
const CHECK_BYTES: &[u8] = b"123456789";

// Create your own CRC.
let mut crc32c = CRC::<u32>::new(
    Endian::Little, // endian
    0x1edc6f41, // poly
    0xffffffff, // init
    true, // refin
    true, // refout
    0xffffffff, // xorout
);

// Checksum
assert_eq!(crc32c.checksum(CHECK_BYTES), 0xe3069283);
// Is error-free?
let checksum = crc32c.checksum_to_endian_bytes(CHECK_BYTES);
let bytes = [CHECK_BYTES, &checksum].concat();
assert!(crc32c.is_error_free_bytes(&bytes));