2 releases

0.1.2 Dec 13, 2023
0.1.1 Oct 21, 2021
0.1.0 Oct 21, 2021

#465 in Math

Download history 36/week @ 2023-12-28 340/week @ 2024-01-04 174/week @ 2024-01-11 423/week @ 2024-01-18 293/week @ 2024-01-25 10/week @ 2024-02-01 12/week @ 2024-02-08 10/week @ 2024-02-15 17/week @ 2024-02-22 9/week @ 2024-02-29 32/week @ 2024-03-07 21/week @ 2024-03-14 29/week @ 2024-03-21 26/week @ 2024-03-28 6/week @ 2024-04-04

61 downloads per month

MIT/Apache

11KB
224 lines

Sonnenbrille

"Son­nen­bril­le, die -- Brille mit dunkel getönten Gläsern, die die Augen vor zu starker Helligkeit des Sonnenlichts schützen soll" -- Duden

"Sunglasses, feminine -- Glasses with dark-toned lenses, that protect the eyes from bright sunlight"

There are many articles, references and online resources for the Cyclic Redundancy Check, but I was surprised and greatly helped by the clarity and comprehensiveness of Sunshine 2K's Understanding and implementing CRC (Cyclic Redundancy Check) calculation. Along with the author's online implementation, this illuminating article made it possible for me to understand, implement and test an 8-bit CRC calculator in Rust.

extern crate sonnenbrille;
use sonnenbrille::CRC8;

fn crc8(num: u32): u8 {
    let calculator = CRC8::default();
    return calculator.of(&num.to_be_bytes(), 0x00);
}

fn main() {
    let num: u32 = 0x31313233;
    let calculator = CRC8::default();
    let checksum = calculator.of(&num.to_be_bytes(), 0x00);
    assert_eq!(checksum, 0x7F);
}

No runtime deps