]>
code.octet-stream.net Git - m17rt/blob - m17core/src/crc.rs
1 pub const M17_ALG
: crc
::Algorithm
<u16> = crc
::Algorithm
{
12 pub fn m17_crc(input
: &[u8]) -> u16 {
13 let crc
= crc
::Crc
::<u16>::new(&M17_ALG
);
14 let mut digest
= crc
.digest();
24 fn crc_test_vectors() {
25 assert_eq
!(m17_crc(&[]), 0xFFFF);
26 assert_eq
!(m17_crc("A".as_bytes()), 0x206E);
27 assert_eq
!(m17_crc("123456789".as_bytes()), 0x772B);
28 let bytes
: Vec
<u8> = (0x00..=0xFF).collect();
29 assert_eq
!(m17_crc(&bytes
), 0x1C31);