crc_any/lib.rs
1/*!
2# CRC Any
3
4To compute CRC values by providing the length of bits, expression, reflection, an initial value and a final xor value. It has many built-in CRC functions.
5
6## Usage
7
8You can use `create_crc` associated function to create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value. For example, if you want to compute a CRC-24 value.
9
10```rust
11use crc_any::CRC;
12
13let mut crc24 = CRC::create_crc(0x0000000000864CFB, 24, 0x0000000000B704CE, 0x0000000000000000, false);
14
15crc24.digest(b"hello");
16*/
17#![cfg_attr(
18 feature = "alloc",
19 doc = "
20
21assert_eq!([71, 245, 138].to_vec(), crc24.get_crc_vec_be());
22assert_eq!(\"0x47F58A\", &crc24.to_string());
23"
24)]
25/*!
26```
27 */
28/*!
29To simplify the usage, there are several common versions of CRC whose computing functions are already built-in.
30
31 * crc3gsm
32 * crc4itu
33 * crc4interlaken
34 * crc5epc
35 * crc5itu
36 * crc5usb
37 * crc6cdma2000_a
38 * crc6cdma2000_b
39 * crc6darc
40 * crc6gsm
41 * crc6itu
42 * crc7
43 * crc7umts
44 * crc8
45 * crc8cdma2000
46 * crc8darc
47 * crc8dvb_s2
48 * crc8ebu
49 * crc8icode
50 * crc8itu
51 * crc8maxim
52 * crc8rohc
53 * crc8wcdma
54 * crc10
55 * crc10cdma2000
56 * crc10gsm
57 * crc11
58 * crc12
59 * crc12cdma2000
60 * crc12gsm
61 * crc13bbc
62 * crc14darc
63 * crc14gsm
64 * crc15can
65 * crc15mpt1327
66 * crc16
67 * crc16ccitt_false
68 * crc16aug_ccitt
69 * crc16buypass
70 * crc16cdma2000
71 * crc16dds_110
72 * crc16dect_r
73 * crc16dect_x
74 * crc16dnp
75 * crc16en_13757
76 * crc16genibus
77 * crc16maxim
78 * crc16mcrf4cc
79 * crc16riello
80 * crc16t10_dif
81 * crc16teledisk
82 * crc16tms13157
83 * crc16usb
84 * crc_a
85 * crc16kermit
86 * crc16modbus
87 * crc16_x25
88 * crc16xmodem
89 * crc17can
90 * crc21can
91 * crc24
92 * crc24ble
93 * crc24flexray_a
94 * crc24flexray_b
95 * crc24lte_a
96 * crc24lte_b
97 * crc24os9
98 * crc30cdma
99 * crc32
100 * It also called `crc32b` in `mhash`.
101 * crc32mhash
102 * `mhash` is a common library which has two weird versions of CRC32 called `crc32` and `crc32b`. `crc32` and `crc32mhash` in this module are `crc32b` and `crc32` in mhash respectively.
103 * crc32bzip2
104 * crc32c
105 * crc32d
106 * crc32mpeg2
107 * crc32posix
108 * crc32q
109 * crc32jamcrc
110 * crc32xfer
111 * crc40gsm
112 * crc64
113 * crc64iso
114 * crc64we
115 * crc64jones
116
117For instance,
118
119```rust
120use crc_any::CRC;
121
122let mut crc64 = CRC::crc64();
123
124crc64.digest(b"hello");
125*/
126#![cfg_attr(
127 feature = "alloc",
128 doc = "
129
130assert_eq!([64, 84, 74, 48, 97, 55, 182, 236].to_vec(), crc64.get_crc_vec_be());
131assert_eq!(\"0x40544A306137B6EC\", &crc64.to_string());
132"
133)]
134/*!
135```
136*/
137/*!
138After getting a CRC value, you can still use the `digest` method to continue computing the next CRC values.
139
140## Heapless Support
141
142To make sure this crate will not use heap memory allocation, you can disable the default features.
143
144```toml
145[dependencies.crc-any]
146version = "*"
147default-features = false
148```
149
150After doing that, the `get_crc_vec_be` and `get_crc_vec_le` methods can not be used. But if you still need this crate to return a `Vec` without dynamic allocation, you can enable the `heapless` feature to make the `get_crc_heapless_vec_be` and `get_crc_heapless_vec_le` methods available.
151
152```toml
153[dependencies.crc-any]
154version = "*"
155default-features = false
156features = ["heapless"]
157```
158 */
159
160#![cfg_attr(not(feature = "std"), no_std)]
161
162#[cfg(feature = "alloc")]
163#[macro_use]
164extern crate alloc;
165
166#[cfg(feature = "alloc")]
167use alloc::fmt::{self, Display, Formatter};
168#[cfg(feature = "alloc")]
169use alloc::vec::Vec;
170
171#[cfg(feature = "heapless")]
172use heapless::Vec as HeaplessVec;
173
174mod constants;
175mod crc_u16;
176mod crc_u32;
177mod crc_u64;
178mod crc_u8;
179mod lookup_table;
180
181pub use crc_u16::CRCu16;
182pub use crc_u32::CRCu32;
183pub use crc_u64::CRCu64;
184pub use crc_u8::CRCu8;
185
186#[allow(clippy::upper_case_acronyms, clippy::large_enum_variant)]
187/// This struct can help you compute a CRC value.
188#[cfg_attr(feature = "alloc", derive(Debug))]
189pub enum CRC {
190 CRCu8(CRCu8),
191 CRCu16(CRCu16),
192 CRCu32(CRCu32),
193 CRCu64(CRCu64),
194}
195
196#[cfg(feature = "alloc")]
197impl Display for CRC {
198 #[inline]
199 fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
200 match self {
201 CRC::CRCu8(crc) => Display::fmt(crc, f),
202 CRC::CRCu16(crc) => Display::fmt(crc, f),
203 CRC::CRCu32(crc) => Display::fmt(crc, f),
204 CRC::CRCu64(crc) => Display::fmt(crc, f),
205 }
206 }
207}
208
209impl CRC {
210 /// Create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value.
211 #[inline]
212 pub fn create_crc(poly: u64, bits: u8, initial: u64, final_xor: u64, reflect: bool) -> CRC {
213 if bits <= 8 {
214 Self::create_crc_u8(poly as u8, bits, initial as u8, final_xor as u8, reflect)
215 } else if bits <= 16 {
216 Self::create_crc_u16(poly as u16, bits, initial as u16, final_xor as u16, reflect)
217 } else if bits <= 32 {
218 Self::create_crc_u32(poly as u32, bits, initial as u32, final_xor as u32, reflect)
219 } else if bits <= 64 {
220 Self::create_crc_u64(poly, bits, initial, final_xor, reflect)
221 } else {
222 unimplemented!()
223 }
224 }
225
226 /// Create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value.
227 #[inline]
228 pub fn create_crc_u8(poly: u8, bits: u8, initial: u8, final_xor: u8, reflect: bool) -> CRC {
229 let crc = CRCu8::create_crc(poly, bits, initial, final_xor, reflect);
230
231 CRC::CRCu8(crc)
232 }
233
234 /// Create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value.
235 #[inline]
236 pub fn create_crc_u16(poly: u16, bits: u8, initial: u16, final_xor: u16, reflect: bool) -> CRC {
237 let crc = CRCu16::create_crc(poly, bits, initial, final_xor, reflect);
238
239 CRC::CRCu16(crc)
240 }
241
242 /// Create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value.
243 #[inline]
244 pub fn create_crc_u32(poly: u32, bits: u8, initial: u32, final_xor: u32, reflect: bool) -> CRC {
245 let crc = CRCu32::create_crc(poly, bits, initial, final_xor, reflect);
246
247 CRC::CRCu32(crc)
248 }
249
250 /// Create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value.
251 #[inline]
252 pub fn create_crc_u64(poly: u64, bits: u8, initial: u64, final_xor: u64, reflect: bool) -> CRC {
253 let crc = CRCu64::create_crc(poly, bits, initial, final_xor, reflect);
254
255 CRC::CRCu64(crc)
256 }
257
258 /// Digest some data.
259 #[inline]
260 pub fn digest<T: ?Sized + AsRef<[u8]>>(&mut self, data: &T) {
261 match self {
262 CRC::CRCu8(crc) => crc.digest(data),
263 CRC::CRCu16(crc) => crc.digest(data),
264 CRC::CRCu32(crc) => crc.digest(data),
265 CRC::CRCu64(crc) => crc.digest(data),
266 }
267 }
268
269 /// Reset the sum.
270 #[inline]
271 pub fn reset(&mut self) {
272 match self {
273 CRC::CRCu8(crc) => crc.reset(),
274 CRC::CRCu16(crc) => crc.reset(),
275 CRC::CRCu32(crc) => crc.reset(),
276 CRC::CRCu64(crc) => crc.reset(),
277 }
278 }
279
280 /// Get the current CRC value (it always returns a `u64` value). You can continue calling `digest` method even after getting a CRC value.
281 #[inline]
282 pub fn get_crc(&mut self) -> u64 {
283 match self {
284 CRC::CRCu8(crc) => u64::from(crc.get_crc()),
285 CRC::CRCu16(crc) => u64::from(crc.get_crc()),
286 CRC::CRCu32(crc) => u64::from(crc.get_crc()),
287 CRC::CRCu64(crc) => crc.get_crc(),
288 }
289 }
290}
291
292#[cfg(feature = "alloc")]
293impl CRC {
294 /// Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling `digest` method even after getting a CRC value.
295 #[inline]
296 pub fn get_crc_vec_le(&mut self) -> Vec<u8> {
297 match self {
298 CRC::CRCu8(crc) => vec![crc.get_crc()],
299 CRC::CRCu16(crc) => crc.get_crc_vec_le(),
300 CRC::CRCu32(crc) => crc.get_crc_vec_le(),
301 CRC::CRCu64(crc) => crc.get_crc_vec_le(),
302 }
303 }
304
305 /// Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling `digest` method even after getting a CRC value.
306 #[inline]
307 pub fn get_crc_vec_be(&mut self) -> Vec<u8> {
308 match self {
309 CRC::CRCu8(crc) => vec![crc.get_crc()],
310 CRC::CRCu16(crc) => crc.get_crc_vec_be(),
311 CRC::CRCu32(crc) => crc.get_crc_vec_be(),
312 CRC::CRCu64(crc) => crc.get_crc_vec_be(),
313 }
314 }
315}
316
317#[cfg(feature = "heapless")]
318impl CRC {
319 /// Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling `digest` method even after getting a CRC value.
320 pub fn get_crc_heapless_vec_le(&mut self) -> HeaplessVec<u8, 8> {
321 let mut vec = HeaplessVec::new();
322
323 let bits = match self {
324 CRC::CRCu8(crc) => f64::from(crc.bits),
325 CRC::CRCu16(crc) => f64::from(crc.bits),
326 CRC::CRCu32(crc) => f64::from(crc.bits),
327 CRC::CRCu64(crc) => f64::from(crc.bits),
328 };
329
330 let e = ((bits + 7f64) / 8f64) as u64;
331
332 let e_dec = e - 1;
333
334 let o = e_dec * 8;
335
336 let crc = self.get_crc();
337
338 for i in 0..e {
339 vec.push((crc << ((e_dec - i) * 8) >> o) as u8).unwrap();
340 }
341
342 vec
343 }
344
345 /// Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling `digest` method even after getting a CRC value.
346 pub fn get_crc_heapless_vec_be(&mut self) -> HeaplessVec<u8, 8> {
347 let mut vec = HeaplessVec::new();
348
349 let bits = match self {
350 CRC::CRCu8(crc) => f64::from(crc.bits),
351 CRC::CRCu16(crc) => f64::from(crc.bits),
352 CRC::CRCu32(crc) => f64::from(crc.bits),
353 CRC::CRCu64(crc) => f64::from(crc.bits),
354 };
355
356 let e = ((bits + 7f64) / 8f64) as u64;
357
358 let e_dec = e - 1;
359
360 let o = e_dec * 8;
361
362 let crc = self.get_crc();
363
364 for i in 0..e {
365 vec.push((crc << (i * 8) >> o) as u8).unwrap();
366 }
367
368 vec
369 }
370}
371
372impl CRC {
373 // TODO: CRC-3
374
375 /// |Check|Poly|Init|Ref|XorOut|
376 /// |---|---|---|---|---|
377 /// |0x4|0x3|0x0|false|0x7|
378 ///
379 /// ```
380 /// # use crc_any::CRC;
381 /// let mut crc = CRC::crc3gsm();
382 /// crc.digest(b"123456789");
383 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x4\", &crc.to_string());")]
384 /// ```
385 pub fn crc3gsm() -> CRC {
386 CRC::CRCu8(CRCu8::crc3gsm())
387 }
388
389 // TODO: CRC-4
390
391 /// |Check|Poly|Init|Ref|XorOut|
392 /// |---|---|---|---|---|
393 /// |0x7|0x3 (rev: 0xC)|0x0|true|0x0|
394 ///
395 /// ```
396 /// # use crc_any::CRC;
397 /// let mut crc = CRC::crc4itu();
398 /// crc.digest(b"123456789");
399 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x7\", &crc.to_string());")]
400 /// ```
401 pub fn crc4itu() -> CRC {
402 CRC::CRCu8(CRCu8::crc4itu())
403 }
404
405 /// |Check|Poly|Init|Ref|XorOut|
406 /// |---|---|---|---|---|
407 /// |0xB|0x3|0xF|false|0xF|
408 ///
409 /// ```
410 /// # use crc_any::CRC;
411 /// let mut crc = CRC::crc4interlaken();
412 /// crc.digest(b"123456789");
413 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xB\", &crc.to_string());")]
414 /// ```
415 pub fn crc4interlaken() -> CRC {
416 CRC::CRCu8(CRCu8::crc4interlaken())
417 }
418
419 // TODO: CRC-5
420
421 /// |Check|Poly|Init|Ref|XorOut|
422 /// |---|---|---|---|---|
423 /// |0x00|0x09|0x09|false|0x00|
424 ///
425 /// ```
426 /// # use crc_any::CRC;
427 /// let mut crc = CRC::crc5epc();
428 /// crc.digest(b"123456789");
429 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x00\", &crc.to_string());")]
430 /// ```
431 pub fn crc5epc() -> CRC {
432 CRC::CRCu8(CRCu8::crc5epc())
433 }
434
435 /// |Check|Poly|Init|Ref|XorOut|
436 /// |---|---|---|---|---|
437 /// |0x07|0x15 (rev: 0x15)|0x00|true|0x00|
438 ///
439 /// ```
440 /// # use crc_any::CRC;
441 /// let mut crc = CRC::crc5itu();
442 /// crc.digest(b"123456789");
443 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x07\", &crc.to_string());")]
444 /// ```
445 pub fn crc5itu() -> CRC {
446 CRC::CRCu8(CRCu8::crc5itu())
447 }
448
449 /// |Check|Poly|Init|Ref|XorOut|
450 /// |---|---|---|---|---|
451 /// |0x19|0x05 (rev: 0x14)|0x1F|true|0x1F|
452 ///
453 /// ```
454 /// # use crc_any::CRC;
455 /// let mut crc = CRC::crc5usb();
456 /// crc.digest(b"123456789");
457 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x19\", &crc.to_string());")]
458 /// ```
459 pub fn crc5usb() -> CRC {
460 CRC::CRCu8(CRCu8::crc5usb())
461 }
462
463 // TODO: CRC-6
464
465 /// |Check|Poly|Init|Ref|XorOut|
466 /// |---|---|---|---|---|
467 /// |0x0D|0x27|0x3F|false|0x00|
468 ///
469 /// ```
470 /// # use crc_any::CRC;
471 /// let mut crc = CRC::crc6cdma2000_a();
472 /// crc.digest(b"123456789");
473 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x0D\", &crc.to_string());")]
474 /// ```
475 #[inline]
476 pub fn crc6cdma2000_a() -> CRC {
477 CRC::CRCu8(CRCu8::crc6cdma2000_a())
478 }
479
480 /// |Check|Poly|Init|Ref|XorOut|
481 /// |---|---|---|---|---|
482 /// |0x3B|0x07|0x3F|false|0x00|
483 ///
484 /// ```
485 /// # use crc_any::CRC;
486 /// let mut crc = CRC::crc6cdma2000_b();
487 /// crc.digest(b"123456789");
488 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x3B\", &crc.to_string());")]
489 /// ```
490 #[inline]
491 pub fn crc6cdma2000_b() -> CRC {
492 CRC::CRCu8(CRCu8::crc6cdma2000_b())
493 }
494
495 /// |Check|Poly|Init|Ref|XorOut|
496 /// |---|---|---|---|---|
497 /// |0x26|0x19 (rev: 0x26)|0x00|true|0x00|
498 ///
499 /// ```
500 /// # use crc_any::CRC;
501 /// let mut crc = CRC::crc6darc();
502 /// crc.digest(b"123456789");
503 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x26\", &crc.to_string());")]
504 /// ```
505 #[inline]
506 pub fn crc6darc() -> CRC {
507 CRC::CRCu8(CRCu8::crc6darc())
508 }
509
510 /// |Check|Poly|Init|Ref|XorOut|
511 /// |---|---|---|---|---|
512 /// |0x13|0x2F|0x00|false|0x3F|
513 ///
514 /// ```
515 /// # use crc_any::CRC;
516 /// let mut crc = CRC::crc6gsm();
517 /// crc.digest(b"123456789");
518 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x13\", &crc.to_string());")]
519 /// ```
520 #[inline]
521 pub fn crc6gsm() -> CRC {
522 CRC::CRCu8(CRCu8::crc6gsm())
523 }
524
525 /// |Check|Poly|Init|Ref|XorOut|
526 /// |---|---|---|---|---|
527 /// |0x06|0x03 (rev: 0x30)|0x00|true|0x00|
528 ///
529 /// ```
530 /// # use crc_any::CRC;
531 /// let mut crc = CRC::crc6itu();
532 /// crc.digest(b"123456789");
533 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x06\", &crc.to_string());")]
534 /// ```
535 #[inline]
536 pub fn crc6itu() -> CRC {
537 CRC::CRCu8(CRCu8::crc6itu())
538 }
539
540 // TODO: CRC-7
541
542 /// |Check|Poly|Init|Ref|XorOut|
543 /// |---|---|---|---|---|
544 /// |0x75|0x09|0x00|false|0x00|
545 ///
546 /// ```
547 /// # use crc_any::CRC;
548 /// let mut crc = CRC::crc7();
549 /// crc.digest(b"123456789");
550 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x75\", &crc.to_string());")]
551 /// ```
552 #[inline]
553 pub fn crc7() -> CRC {
554 CRC::CRCu8(CRCu8::crc7())
555 }
556
557 /// |Check|Poly|Init|Ref|XorOut|
558 /// |---|---|---|---|---|
559 /// |0x61|0x45|0x00|false|0x00|
560 ///
561 /// ```
562 /// # use crc_any::CRC;
563 /// let mut crc = CRC::crc7umts();
564 /// crc.digest(b"123456789");
565 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x61\", &crc.to_string());")]
566 /// ```
567 #[inline]
568 pub fn crc7umts() -> CRC {
569 CRC::CRCu8(CRCu8::crc7umts())
570 }
571
572 // TODO: CRC-8
573
574 /// |Check|Poly|Init|Ref|XorOut|
575 /// |---|---|---|---|---|
576 /// |0xF4|0x07|0x00|false|0x00|
577 ///
578 /// ```
579 /// # use crc_any::CRC;
580 /// let mut crc = CRC::crc8();
581 /// crc.digest(b"123456789");
582 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xF4\", &crc.to_string());")]
583 /// ```
584 #[inline]
585 pub fn crc8() -> CRC {
586 CRC::CRCu8(CRCu8::crc8())
587 }
588
589 /// |Check|Poly|Init|Ref|XorOut|
590 /// |---|---|---|---|---|
591 /// |0xDA|0x9B|0xFF|false|0x00|
592 ///
593 /// ```
594 /// # use crc_any::CRC;
595 /// let mut crc = CRC::crc8cdma2000();
596 /// crc.digest(b"123456789");
597 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xDA\", &crc.to_string());")]
598 /// ```
599 #[inline]
600 pub fn crc8cdma2000() -> CRC {
601 CRC::CRCu8(CRCu8::crc8cdma2000())
602 }
603
604 /// |Check|Poly|Init|Ref|XorOut|
605 /// |---|---|---|---|---|
606 /// |0xDA|0x39 (rev: 0x9C)|0x00|true|0x00|
607 ///
608 /// ```
609 /// # use crc_any::CRC;
610 /// let mut crc = CRC::crc8darc();
611 /// crc.digest(b"123456789");
612 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x15\", &crc.to_string());")]
613 /// ```
614 #[inline]
615 pub fn crc8darc() -> CRC {
616 CRC::CRCu8(CRCu8::crc8darc())
617 }
618
619 /// |Check|Poly|Init|Ref|XorOut|
620 /// |---|---|---|---|---|
621 /// |0xBC|0xD5|0x00|false|0x00|
622 ///
623 /// ```
624 /// # use crc_any::CRC;
625 /// let mut crc = CRC::crc8dvb_s2();
626 /// crc.digest(b"123456789");
627 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xBC\", &crc.to_string());")]
628 /// ```
629 #[inline]
630 pub fn crc8dvb_s2() -> CRC {
631 CRC::CRCu8(CRCu8::crc8dvb_s2())
632 }
633
634 /// |Check|Poly|Init|Ref|XorOut|
635 /// |---|---|---|---|---|
636 /// |0x97|0x1D (rev: 0xB8)|0xFF|true|0x00|
637 ///
638 /// ```
639 /// # use crc_any::CRC;
640 /// let mut crc = CRC::crc8ebu();
641 /// crc.digest(b"123456789");
642 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x97\", &crc.to_string());")]
643 /// ```
644 #[inline]
645 pub fn crc8ebu() -> CRC {
646 CRC::CRCu8(CRCu8::crc8ebu())
647 }
648
649 /// |Check|Poly|Init|Ref|XorOut|
650 /// |---|---|---|---|---|
651 /// |0x7E|0x1D|0xFD|false|0x00|
652 ///
653 /// ```
654 /// # use crc_any::CRC;
655 /// let mut crc = CRC::crc8icode();
656 /// crc.digest(b"123456789");
657 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x7E\", &crc.to_string());")]
658 /// ```
659 #[inline]
660 pub fn crc8icode() -> CRC {
661 CRC::CRCu8(CRCu8::crc8icode())
662 }
663
664 /// |Check|Poly|Init|Ref|XorOut|
665 /// |---|---|---|---|---|
666 /// |0xA1|0x07|0x00|false|0x55|
667 ///
668 /// ```
669 /// # use crc_any::CRC;
670 /// let mut crc = CRC::crc8itu();
671 /// crc.digest(b"123456789");
672 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xA1\", &crc.to_string());")]
673 /// ```
674 #[inline]
675 pub fn crc8itu() -> CRC {
676 CRC::CRCu8(CRCu8::crc8itu())
677 }
678
679 /// |Check|Poly|Init|Ref|XorOut|
680 /// |---|---|---|---|---|
681 /// |0xA1|0x31 (rev: 0x8C)|0x00|true|0x00|
682 ///
683 /// ```
684 /// # use crc_any::CRC;
685 /// let mut crc = CRC::crc8maxim();
686 /// crc.digest(b"123456789");
687 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xA1\", &crc.to_string());")]
688 /// ```
689 #[inline]
690 pub fn crc8maxim() -> CRC {
691 CRC::CRCu8(CRCu8::crc8maxim())
692 }
693
694 /// |Check|Poly|Init|Ref|XorOut|
695 /// |---|---|---|---|---|
696 /// |0xD0|0x07 (rev: 0xE0)|0xFF|true|0x00|
697 ///
698 /// ```
699 /// # use crc_any::CRC;
700 /// let mut crc = CRC::crc8rohc();
701 /// crc.digest(b"123456789");
702 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xD0\", &crc.to_string());")]
703 /// ```
704 #[inline]
705 pub fn crc8rohc() -> CRC {
706 CRC::CRCu8(CRCu8::crc8rohc())
707 }
708
709 /// |Check|Poly|Init|Ref|XorOut|
710 /// |---|---|---|---|---|
711 /// |0x25|0x9B (rev: 0xD9)|0x00|true|0x00|
712 ///
713 /// ```
714 /// # use crc_any::CRC;
715 /// let mut crc = CRC::crc8wcdma();
716 /// crc.digest(b"123456789");
717 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x25\", &crc.to_string());")]
718 /// ```
719 #[inline]
720 pub fn crc8wcdma() -> CRC {
721 CRC::CRCu8(CRCu8::crc8wcdma())
722 }
723
724 // TODO: CRC-10
725
726 /// |Check|Poly|Init|Ref|XorOut|
727 /// |---|---|---|---|---|
728 /// |0x199|0x233|0x000|false|0x000|
729 ///
730 /// ```
731 /// # use crc_any::CRC;
732 /// let mut crc = CRC::crc10();
733 /// crc.digest(b"123456789");
734 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x199\", &crc.to_string());")]
735 /// ```
736 #[inline]
737 pub fn crc10() -> CRC {
738 CRC::CRCu16(CRCu16::crc10())
739 }
740
741 /// |Check|Poly|Init|Ref|XorOut|
742 /// |---|---|---|---|---|
743 /// |0x233|0x3D9|0x3FF|false|0x000|
744 ///
745 /// ```
746 /// # use crc_any::CRC;
747 /// let mut crc = CRC::crc10cdma2000();
748 /// crc.digest(b"123456789");
749 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x233\", &crc.to_string());")]
750 /// ```
751 #[inline]
752 pub fn crc10cdma2000() -> CRC {
753 CRC::CRCu16(CRCu16::crc10cdma2000())
754 }
755
756 /// |Check|Poly|Init|Ref|XorOut|
757 /// |---|---|---|---|---|
758 /// |0x12A|0x175|0x000|false|0x3FF|
759 ///
760 /// ```
761 /// # use crc_any::CRC;
762 /// let mut crc = CRC::crc10gsm();
763 /// crc.digest(b"123456789");
764 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x12A\", &crc.to_string());")]
765 /// ```
766 #[inline]
767 pub fn crc10gsm() -> CRC {
768 CRC::CRCu16(CRCu16::crc10gsm())
769 }
770
771 // TODO: CRC-11
772
773 /// |Check|Poly|Init|Ref|XorOut|
774 /// |---|---|---|---|---|
775 /// |0x5A3|0x385|0x01a|false|0x000|
776 ///
777 /// ```
778 /// # use crc_any::CRC;
779 /// let mut crc = CRC::crc11();
780 /// crc.digest(b"123456789");
781 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x5A3\", &crc.to_string());")]
782 /// ```
783 #[inline]
784 pub fn crc11() -> CRC {
785 CRC::CRCu16(CRCu16::crc11())
786 }
787
788 // TODO: CRC-12
789
790 /// |Check|Poly|Init|Ref|XorOut|
791 /// |---|---|---|---|---|
792 /// |0xF5B|0x080F|0x0000|false|0x0000|
793 ///
794 /// ```
795 /// # use crc_any::CRC;
796 /// let mut crc = CRC::crc12();
797 /// crc.digest(b"123456789");
798 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xF5B\", &crc.to_string());")]
799 /// ```
800 #[inline]
801 pub fn crc12() -> CRC {
802 CRC::CRCu16(CRCu16::crc12())
803 }
804
805 /// |Check|Poly|Init|Ref|XorOut|
806 /// |---|---|---|---|---|
807 /// |0xD4D|0x0F13|0x0FFF|false|0x0000|
808 ///
809 /// ```
810 /// # use crc_any::CRC;
811 /// let mut crc = CRC::crc12cdma2000();
812 /// crc.digest(b"123456789");
813 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xD4D\", &crc.to_string());")]
814 /// ```
815 #[inline]
816 pub fn crc12cdma2000() -> CRC {
817 CRC::CRCu16(CRCu16::crc12cdma2000())
818 }
819
820 /// |Check|Poly|Init|Ref|XorOut|
821 /// |---|---|---|---|---|
822 /// |0xB34|0x0D31|0x0000|false|0x0FFF|
823 ///
824 /// ```
825 /// # use crc_any::CRC;
826 /// let mut crc = CRC::crc12gsm();
827 /// crc.digest(b"123456789");
828 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xB34\", &crc.to_string());")]
829 /// ```
830 #[inline]
831 pub fn crc12gsm() -> CRC {
832 CRC::CRCu16(CRCu16::crc12gsm())
833 }
834
835 // TODO: CRC-13
836
837 /// |Check|Poly|Init|Ref|XorOut|
838 /// |---|---|---|---|---|
839 /// |0x04FA|0x1CF5|0x0000|false|0x0000|
840 ///
841 /// ```
842 /// # use crc_any::CRC;
843 /// let mut crc = CRC::crc13bbc();
844 /// crc.digest(b"123456789");
845 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x04FA\", &crc.to_string());")]
846 /// ```
847 #[inline]
848 pub fn crc13bbc() -> CRC {
849 CRC::CRCu16(CRCu16::crc13bbc())
850 }
851
852 // TODO: CRC-14
853
854 /// |Check|Poly|Init|Ref|XorOut|
855 /// |---|---|---|---|---|
856 /// |0x082D|0x0805 (rev: 0x2804)|0x0000|true|0x0000|
857 ///
858 /// ```
859 /// # use crc_any::CRC;
860 /// let mut crc = CRC::crc14darc();
861 /// crc.digest(b"123456789");
862 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x082D\", &crc.to_string());")]
863 /// ```
864 #[inline]
865 pub fn crc14darc() -> CRC {
866 CRC::CRCu16(CRCu16::crc14darc())
867 }
868
869 /// |Check|Poly|Init|Ref|XorOut|
870 /// |---|---|---|---|---|
871 /// |0x30AE|0x202D|0x0000|false|0x3FFF|
872 ///
873 /// ```
874 /// # use crc_any::CRC;
875 /// let mut crc = CRC::crc14gsm();
876 /// crc.digest(b"123456789");
877 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x30AE\", &crc.to_string());")]
878 /// ```
879 #[inline]
880 pub fn crc14gsm() -> CRC {
881 CRC::CRCu16(CRCu16::crc14gsm())
882 }
883
884 // TODO: CRC-15
885
886 /// |Check|Poly|Init|Ref|XorOut|
887 /// |---|---|---|---|---|
888 /// |0x059E|0x4599|0x0000|false|0x0000|
889 ///
890 /// ```
891 /// # use crc_any::CRC;
892 /// let mut crc = CRC::crc15can();
893 /// crc.digest(b"123456789");
894 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x059E\", &crc.to_string());")]
895 /// ```
896 #[inline]
897 pub fn crc15can() -> CRC {
898 CRC::CRCu16(CRCu16::crc15can())
899 }
900
901 /// |Check|Poly|Init|Ref|XorOut|
902 /// |---|---|---|---|---|
903 /// |0x2566|0x6815|0x0000|false|0x0001|
904 ///
905 /// ```
906 /// # use crc_any::CRC;
907 /// let mut crc = CRC::crc15mpt1327();
908 /// crc.digest(b"123456789");
909 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x2566\", &crc.to_string());")]
910 /// ```
911 #[inline]
912 pub fn crc15mpt1327() -> CRC {
913 CRC::CRCu16(CRCu16::crc15mpt1327())
914 }
915
916 // TODO: CRC-16
917
918 /// |Check|Poly|Init|Ref|XorOut|
919 /// |---|---|---|---|---|
920 /// |0xBB3D|0x8005 (rev: 0xA001)|0x0000|true|0x0000|
921 ///
922 /// ```
923 /// # use crc_any::CRC;
924 /// let mut crc = CRC::crc16();
925 /// crc.digest(b"123456789");
926 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xBB3D\", &crc.to_string());")]
927 /// ```
928 #[inline]
929 pub fn crc16() -> CRC {
930 CRC::CRCu16(CRCu16::crc16())
931 }
932
933 /// |Check|Poly|Init|Ref|XorOut|
934 /// |---|---|---|---|---|
935 /// |0x29B1|0x1021|0xFFFF|false|0x0000|
936 ///
937 /// ```
938 /// # use crc_any::CRC;
939 /// let mut crc = CRC::crc16ccitt_false();
940 /// crc.digest(b"123456789");
941 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x29B1\", &crc.to_string());")]
942 /// ```
943 #[inline]
944 pub fn crc16ccitt_false() -> CRC {
945 CRC::CRCu16(CRCu16::crc16ccitt_false())
946 }
947
948 /// |Check|Poly|Init|Ref|XorOut|
949 /// |---|---|---|---|---|
950 /// |0xE5CC|0x1021|0x1D0F|false|0x0000|
951 ///
952 /// ```
953 /// # use crc_any::CRC;
954 /// let mut crc = CRC::crc16aug_ccitt();
955 /// crc.digest(b"123456789");
956 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xE5CC\", &crc.to_string());")]
957 /// ```
958 #[inline]
959 pub fn crc16aug_ccitt() -> CRC {
960 CRC::CRCu16(CRCu16::crc16aug_ccitt())
961 }
962
963 /// |Check|Poly|Init|Ref|XorOut|
964 /// |---|---|---|---|---|
965 /// |0xFEE8|0x8005|0x0000|false|0x0000|
966 ///
967 /// ```
968 /// # use crc_any::CRC;
969 /// let mut crc = CRC::crc16buypass();
970 /// crc.digest(b"123456789");
971 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xFEE8\", &crc.to_string());")]
972 /// ```
973 #[inline]
974 pub fn crc16buypass() -> CRC {
975 CRC::CRCu16(CRCu16::crc16buypass())
976 }
977
978 /// |Check|Poly|Init|Ref|XorOut|
979 /// |---|---|---|---|---|
980 /// |0x4C06|0xC867|0xFFFF|false|0x0000|
981 ///
982 /// ```
983 /// # use crc_any::CRC;
984 /// let mut crc = CRC::crc16cdma2000();
985 /// crc.digest(b"123456789");
986 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x4C06\", &crc.to_string());")]
987 /// ```
988 #[inline]
989 pub fn crc16cdma2000() -> CRC {
990 CRC::CRCu16(CRCu16::crc16cdma2000())
991 }
992
993 /// |Check|Poly|Init|Ref|XorOut|
994 /// |---|---|---|---|---|
995 /// |0x9ECF|0x8005|0x800D|false|0x0000|
996 ///
997 /// ```
998 /// # use crc_any::CRC;
999 /// let mut crc = CRC::crc16dds_110();
1000 /// crc.digest(b"123456789");
1001 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x9ECF\", &crc.to_string());")]
1002 /// ```
1003 #[inline]
1004 pub fn crc16dds_110() -> CRC {
1005 CRC::CRCu16(CRCu16::crc16dds_110())
1006 }
1007
1008 /// |Check|Poly|Init|Ref|XorOut|
1009 /// |---|---|---|---|---|
1010 /// |0x007E|0x0589|0x0000|false|0x0001|
1011 ///
1012 /// ```
1013 /// # use crc_any::CRC;
1014 /// let mut crc = CRC::crc16dect_r();
1015 /// crc.digest(b"123456789");
1016 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x007E\", &crc.to_string());")]
1017 /// ```
1018 #[inline]
1019 pub fn crc16dect_r() -> CRC {
1020 CRC::CRCu16(CRCu16::crc16dect_r())
1021 }
1022
1023 /// |Check|Poly|Init|Ref|XorOut|
1024 /// |---|---|---|---|---|
1025 /// |0x007F|0x0589|0x0000|false|0x0000|
1026 ///
1027 /// ```
1028 /// # use crc_any::CRC;
1029 /// let mut crc = CRC::crc16dect_r();
1030 /// crc.digest(b"123456789");
1031 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x007E\", &crc.to_string());")]
1032 /// ```
1033 #[inline]
1034 pub fn crc16dect_x() -> CRC {
1035 CRC::CRCu16(CRCu16::crc16dect_x())
1036 }
1037
1038 /// |Check|Poly|Init|Ref|XorOut|
1039 /// |---|---|---|---|---|
1040 /// |0xEA82|0x3D65 (rev: 0xA6BC)|0x0000|true|0xFFFF|
1041 ///
1042 /// ```
1043 /// # use crc_any::CRC;
1044 /// let mut crc = CRC::crc16dnp();
1045 /// crc.digest(b"123456789");
1046 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xEA82\", &crc.to_string());")]
1047 /// ```
1048 #[inline]
1049 pub fn crc16dnp() -> CRC {
1050 CRC::CRCu16(CRCu16::crc16dnp())
1051 }
1052
1053 /// |Check|Poly|Init|Ref|XorOut|
1054 /// |---|---|---|---|---|
1055 /// |0xC2B7|0x3D65|0x0000|false|0xFFFF|
1056 ///
1057 /// ```
1058 /// # use crc_any::CRC;
1059 /// let mut crc = CRC::crc16en_13757();
1060 /// crc.digest(b"123456789");
1061 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xC2B7\", &crc.to_string());")]
1062 /// ```
1063 #[inline]
1064 pub fn crc16en_13757() -> CRC {
1065 CRC::CRCu16(CRCu16::crc16en_13757())
1066 }
1067
1068 /// |Check|Poly|Init|Ref|XorOut|
1069 /// |---|---|---|---|---|
1070 /// |0xD64E|0x1021|0xFFFF|false|0xFFFF|
1071 ///
1072 /// ```
1073 /// # use crc_any::CRC;
1074 /// let mut crc = CRC::crc16genibus();
1075 /// crc.digest(b"123456789");
1076 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xD64E\", &crc.to_string());")]
1077 /// ```
1078 #[inline]
1079 pub fn crc16genibus() -> CRC {
1080 CRC::CRCu16(CRCu16::crc16genibus())
1081 }
1082
1083 /// |Check|Poly|Init|Ref|XorOut|
1084 /// |---|---|---|---|---|
1085 /// |0x44C2|0x8005 (rev: 0xA001)|0xFFFF|true|0xFFFF|
1086 ///
1087 /// ```
1088 /// # use crc_any::CRC;
1089 /// let mut crc = CRC::crc16maxim();
1090 /// crc.digest(b"123456789");
1091 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x44C2\", &crc.to_string());")]
1092 /// ```
1093 #[inline]
1094 pub fn crc16maxim() -> CRC {
1095 CRC::CRCu16(CRCu16::crc16maxim())
1096 }
1097
1098 /// |Check|Poly|Init|Ref|XorOut|
1099 /// |---|---|---|---|---|
1100 /// |0x6F91|0x1021 (rev: 0x8408)|0xFFFF|true|0x0000|
1101 ///
1102 /// ```
1103 /// # use crc_any::CRC;
1104 /// let mut crc = CRC::crc16mcrf4cc();
1105 /// crc.digest(b"123456789");
1106 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x6F91\", &crc.to_string());")]
1107 /// ```
1108 #[inline]
1109 pub fn crc16mcrf4cc() -> CRC {
1110 CRC::CRCu16(CRCu16::crc16mcrf4cc())
1111 }
1112
1113 /// |Check|Poly|Init|Ref|XorOut|
1114 /// |---|---|---|---|---|
1115 /// |0x63D0|0x1021 (rev: 0x8408)|0xB2AA|true|0x0000|
1116 ///
1117 /// ```
1118 /// # use crc_any::CRC;
1119 /// let mut crc = CRC::crc16riello();
1120 /// crc.digest(b"123456789");
1121 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x63D0\", &crc.to_string());")]
1122 /// ```
1123 #[inline]
1124 pub fn crc16riello() -> CRC {
1125 CRC::CRCu16(CRCu16::crc16riello())
1126 }
1127
1128 /// |Check|Poly|Init|Ref|XorOut|
1129 /// |---|---|---|---|---|
1130 /// |0xD0DB|0x8BB7|0x0000|false|0x0000|
1131 ///
1132 /// ```
1133 /// # use crc_any::CRC;
1134 /// let mut crc = CRC::crc16t10_dif();
1135 /// crc.digest(b"123456789");
1136 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xD0DB\", &crc.to_string());")]
1137 /// ```
1138 #[inline]
1139 pub fn crc16t10_dif() -> CRC {
1140 CRC::CRCu16(CRCu16::crc16t10_dif())
1141 }
1142
1143 /// |Check|Poly|Init|Ref|XorOut|
1144 /// |---|---|---|---|---|
1145 /// |0x0FB3|0xA097|0x0000|false|0x0000|
1146 ///
1147 /// ```
1148 /// # use crc_any::CRC;
1149 /// let mut crc = CRC::crc16teledisk();
1150 /// crc.digest(b"123456789");
1151 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x0FB3\", &crc.to_string());")]
1152 /// ```
1153 #[inline]
1154 pub fn crc16teledisk() -> CRC {
1155 CRC::CRCu16(CRCu16::crc16teledisk())
1156 }
1157
1158 /// |Check|Poly|Init|Ref|XorOut|
1159 /// |---|---|---|---|---|
1160 /// |0x26B1|0x1021 (rev: 0x8408)|0x89EC|true|0x0000|
1161 ///
1162 /// ```
1163 /// # use crc_any::CRC;
1164 /// let mut crc = CRC::crc16tms13157();
1165 /// crc.digest(b"123456789");
1166 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x26B1\", &crc.to_string());")]
1167 /// ```
1168 #[inline]
1169 pub fn crc16tms13157() -> CRC {
1170 CRC::CRCu16(CRCu16::crc16tms13157())
1171 }
1172
1173 /// |Check|Poly|Init|Ref|XorOut|
1174 /// |---|---|---|---|---|
1175 /// |0xB4C8|0x8005 (rev: 0xA001)|0xFFFF|true|0xFFFF|
1176 ///
1177 /// ```
1178 /// # use crc_any::CRC;
1179 /// let mut crc = CRC::crc16usb();
1180 /// crc.digest(b"123456789");
1181 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xB4C8\", &crc.to_string());")]
1182 /// ```
1183 #[inline]
1184 pub fn crc16usb() -> CRC {
1185 CRC::CRCu16(CRCu16::crc16usb())
1186 }
1187
1188 /// |Check|Poly|Init|Ref|XorOut|
1189 /// |---|---|---|---|---|
1190 /// |0xBF05|0x1021 (rev: 0x8408)|0xC6C6|true|0x0000|
1191 ///
1192 /// ```
1193 /// # use crc_any::CRC;
1194 /// let mut crc = CRC::crc_a();
1195 /// crc.digest(b"123456789");
1196 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xBF05\", &crc.to_string());")]
1197 /// ```
1198 #[inline]
1199 pub fn crc_a() -> CRC {
1200 CRC::CRCu16(CRCu16::crc_a())
1201 }
1202
1203 /// |Check|Poly|Init|Ref|XorOut|
1204 /// |---|---|---|---|---|
1205 /// |0x2189|0x1021 (rev: 0x8408)|0x0000|true|0x0000|
1206 ///
1207 /// ```
1208 /// # use crc_any::CRC;
1209 /// let mut crc = CRC::crc16kermit();
1210 /// crc.digest(b"123456789");
1211 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x2189\", &crc.to_string());")]
1212 /// ```
1213 #[inline]
1214 pub fn crc16kermit() -> CRC {
1215 CRC::CRCu16(CRCu16::crc16kermit())
1216 }
1217
1218 /// |Check|Poly|Init|Ref|XorOut|
1219 /// |---|---|---|---|---|
1220 /// |0x4B37|0x8005 (rev: 0xA001)|0xFFFF|true|0x0000|
1221 ///
1222 /// ```
1223 /// # use crc_any::CRC;
1224 /// let mut crc = CRC::crc16modbus();
1225 /// crc.digest(b"123456789");
1226 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x4B37\", &crc.to_string());")]
1227 /// ```
1228 #[inline]
1229 pub fn crc16modbus() -> CRC {
1230 CRC::CRCu16(CRCu16::crc16modbus())
1231 }
1232
1233 /// |Check|Poly|Init|Ref|XorOut|
1234 /// |---|---|---|---|---|
1235 /// |0x906E|0x8005 (rev: 0xA001)|0xFFFF|true|0xFFFF|
1236 ///
1237 /// ```
1238 /// # use crc_any::CRC;
1239 /// let mut crc = CRC::crc16_x25();
1240 /// crc.digest(b"123456789");
1241 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x906E\", &crc.to_string());")]
1242 /// ```
1243 #[inline]
1244 pub fn crc16_x25() -> CRC {
1245 CRC::CRCu16(CRCu16::crc16_x25())
1246 }
1247
1248 /// |Check|Poly|Init|Ref|XorOut|
1249 /// |---|---|---|---|---|
1250 /// |0x31C3|0x1021|0x0000|false|0x0000|
1251 ///
1252 /// ```
1253 /// # use crc_any::CRC;
1254 /// let mut crc = CRC::crc16xmodem();
1255 /// crc.digest(b"123456789");
1256 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x31C3\", &crc.to_string());")]
1257 /// ```
1258 #[inline]
1259 pub fn crc16xmodem() -> CRC {
1260 CRC::CRCu16(CRCu16::crc16xmodem())
1261 }
1262
1263 // TODO: CRC-17
1264
1265 /// |Check|Poly|Init|Ref|XorOut|
1266 /// |---|---|---|---|---|
1267 /// |0x04F03|0x1685B|0x00000|false|0x00000|
1268 ///
1269 /// ```
1270 /// # use crc_any::CRC;
1271 /// let mut crc = CRC::crc17can();
1272 /// crc.digest(b"123456789");
1273 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x04F03\", &crc.to_string());")]
1274 /// ```
1275 #[inline]
1276 pub fn crc17can() -> CRC {
1277 CRC::CRCu32(CRCu32::crc17can())
1278 }
1279
1280 // TODO: CRC-21
1281
1282 /// |Check|Poly|Init|Ref|XorOut|
1283 /// |---|---|---|---|---|
1284 /// |0x0ED841|0x102899|0x000000|false|0x000000|
1285 ///
1286 /// ```
1287 /// # use crc_any::CRC;
1288 /// let mut crc = CRC::crc21can();
1289 /// crc.digest(b"123456789");
1290 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x0ED841\", &crc.to_string());")]
1291 /// ```
1292 #[inline]
1293 pub fn crc21can() -> CRC {
1294 CRC::CRCu32(CRCu32::crc21can())
1295 }
1296
1297 // TODO: CRC-24
1298
1299 /// |Check|Poly|Init|Ref|XorOut|
1300 /// |---|---|---|---|---|
1301 /// |0x21CF02|0x864CFB|0xB704CE|false|0x000000|
1302 ///
1303 /// ```
1304 /// # use crc_any::CRC;
1305 /// let mut crc = CRC::crc24();
1306 /// crc.digest(b"123456789");
1307 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x21CF02\", &crc.to_string());")]
1308 /// ```
1309 #[inline]
1310 pub fn crc24() -> CRC {
1311 CRC::CRCu32(CRCu32::crc24())
1312 }
1313
1314 /// |Check|Poly|Init|Ref|XorOut|
1315 /// |---|---|---|---|---|
1316 /// |0xC25A56|0x00065B (rev: 0xDA6000)|0x555555|true|0x000000|
1317 ///
1318 /// ```
1319 /// # use crc_any::CRC;
1320 /// let mut crc = CRC::crc24ble();
1321 /// crc.digest(b"123456789");
1322 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xC25A56\", &crc.to_string());")]
1323 /// ```
1324 #[inline]
1325 pub fn crc24ble() -> CRC {
1326 CRC::CRCu32(CRCu32::crc24ble())
1327 }
1328
1329 /// |Check|Poly|Init|Ref|XorOut|
1330 /// |---|---|---|---|---|
1331 /// |0x7979BD|0x5D6DCB|0xFEDCBA|false|0x000000|
1332 ///
1333 /// ```
1334 /// # use crc_any::CRC;
1335 /// let mut crc = CRC::crc24flexray_a();
1336 /// crc.digest(b"123456789");
1337 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x7979BD\", &crc.to_string());")]
1338 /// ```
1339 #[inline]
1340 pub fn crc24flexray_a() -> CRC {
1341 CRC::CRCu32(CRCu32::crc24flexray_a())
1342 }
1343
1344 /// |Check|Poly|Init|Ref|XorOut|
1345 /// |---|---|---|---|---|
1346 /// |0x1F23B8|0x5D6DCB|0xABCDEF|false|0x000000|
1347 ///
1348 /// ```
1349 /// # use crc_any::CRC;
1350 /// let mut crc = CRC::crc24flexray_b();
1351 /// crc.digest(b"123456789");
1352 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x1F23B8\", &crc.to_string());")]
1353 /// ```
1354 #[inline]
1355 pub fn crc24flexray_b() -> CRC {
1356 CRC::CRCu32(CRCu32::crc24flexray_b())
1357 }
1358
1359 /// |Check|Poly|Init|Ref|XorOut|
1360 /// |---|---|---|---|---|
1361 /// |0xCDE703|0x864CFB|0x000000|false|0x000000|
1362 ///
1363 /// ```
1364 /// # use crc_any::CRC;
1365 /// let mut crc = CRC::crc24lte_a();
1366 /// crc.digest(b"123456789");
1367 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xCDE703\", &crc.to_string());")]
1368 /// ```
1369 #[inline]
1370 pub fn crc24lte_a() -> CRC {
1371 CRC::CRCu32(CRCu32::crc24lte_a())
1372 }
1373
1374 /// |Check|Poly|Init|Ref|XorOut|
1375 /// |---|---|---|---|---|
1376 /// |0x23EF52|0x800063|0x000000|false|0x000000|
1377 ///
1378 /// ```
1379 /// # use crc_any::CRC;
1380 /// let mut crc = CRC::crc24lte_b();
1381 /// crc.digest(b"123456789");
1382 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x23EF52\", &crc.to_string());")]
1383 /// ```
1384 #[inline]
1385 pub fn crc24lte_b() -> CRC {
1386 CRC::CRCu32(CRCu32::crc24lte_b())
1387 }
1388
1389 /// |Check|Poly|Init|Ref|XorOut|
1390 /// |---|---|---|---|---|
1391 /// |0x200FA5|0x800063|0xFFFFFF|false|0xFFFFFF|
1392 ///
1393 /// ```
1394 /// # use crc_any::CRC;
1395 /// let mut crc = CRC::crc24os9();
1396 /// crc.digest(b"123456789");
1397 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x200FA5\", &crc.to_string());")]
1398 /// ```
1399 #[inline]
1400 pub fn crc24os9() -> CRC {
1401 CRC::CRCu32(CRCu32::crc24os9())
1402 }
1403
1404 // TODO: CRC-30
1405
1406 /// |Check|Poly|Init|Ref|XorOut|
1407 /// |---|---|---|---|---|
1408 /// |0x04C34ABF|0x2030B9C7|0x3FFFFFFF|false|0x3FFFFFFF|
1409 ///
1410 /// ```
1411 /// # use crc_any::CRC;
1412 /// let mut crc = CRC::crc30cdma();
1413 /// crc.digest(b"123456789");
1414 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x04C34ABF\", &crc.to_string());")]
1415 /// ```
1416 #[inline]
1417 pub fn crc30cdma() -> CRC {
1418 CRC::CRCu32(CRCu32::crc30cdma())
1419 }
1420
1421 // TODO: CRC-32
1422
1423 /// |Check|Poly|Init|Ref|XorOut|
1424 /// |---|---|---|---|---|
1425 /// |0xCBF43926|0x04C11DB7 (rev: 0xEDB88320)|0xFFFFFFFF|true|0xFFFFFFFF|
1426 ///
1427 /// ```
1428 /// # use crc_any::CRC;
1429 /// let mut crc = CRC::crc32();
1430 /// crc.digest(b"123456789");
1431 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xCBF43926\", &crc.to_string());")]
1432 /// ```
1433 #[inline]
1434 pub fn crc32() -> CRC {
1435 CRC::CRCu32(CRCu32::crc32())
1436 }
1437
1438 /// |Check|Poly|Init|Ref|XorOut|
1439 /// |---|---|---|---|---|
1440 /// |0x181989FC|0x04C11DB7|0xFFFFFFFF|false|0xFFFFFFFF|
1441 ///
1442 /// **Output will be reversed by bytes.**
1443 ///
1444 /// ```
1445 /// # use crc_any::CRC;
1446 /// let mut crc = CRC::crc32mhash();
1447 /// crc.digest(b"123456789");
1448 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x181989FC\", &crc.to_string());")]
1449 /// ```
1450 #[inline]
1451 pub fn crc32mhash() -> CRC {
1452 CRC::CRCu32(CRCu32::crc32mhash())
1453 }
1454
1455 /// |Check|Poly|Init|Ref|XorOut|
1456 /// |---|---|---|---|---|
1457 /// |0xFC891918|0x04C11DB7|0xFFFFFFFF|false|0xFFFFFFFF|
1458 ///
1459 /// ```
1460 /// # use crc_any::CRC;
1461 /// let mut crc = CRC::crc32bzip2();
1462 /// crc.digest(b"123456789");
1463 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xFC891918\", &crc.to_string());")]
1464 /// ```
1465 #[inline]
1466 pub fn crc32bzip2() -> CRC {
1467 CRC::CRCu32(CRCu32::crc32bzip2())
1468 }
1469
1470 /// |Check|Poly|Init|Ref|XorOut|
1471 /// |---|---|---|---|---|
1472 /// |0xE3069283|0x1EDC6F41 (rev: 0x82F63B78)|0xFFFFFFFF|true|0xFFFFFFFF|
1473 ///
1474 /// ```
1475 /// # use crc_any::CRC;
1476 /// let mut crc = CRC::crc32c();
1477 /// crc.digest(b"123456789");
1478 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xE3069283\", &crc.to_string());")]
1479 /// ```
1480 #[inline]
1481 pub fn crc32c() -> CRC {
1482 CRC::CRCu32(CRCu32::crc32c())
1483 }
1484
1485 /// |Check|Poly|Init|Ref|XorOut|
1486 /// |---|---|---|---|---|
1487 /// |0x87315576|0xA833982B (rev: 0xD419CC15)|0xFFFFFFFF|true|0xFFFFFFFF|
1488 ///
1489 /// ```
1490 /// # use crc_any::CRC;
1491 /// let mut crc = CRC::crc32d();
1492 /// crc.digest(b"123456789");
1493 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x87315576\", &crc.to_string());")]
1494 /// ```
1495 #[inline]
1496 pub fn crc32d() -> CRC {
1497 CRC::CRCu32(CRCu32::crc32d())
1498 }
1499
1500 /// |Check|Poly|Init|Ref|XorOut|
1501 /// |---|---|---|---|---|
1502 /// |0x0376E6E7|0x04C11DB7|0xFFFFFFFF|false|0x00000000|
1503 ///
1504 /// ```
1505 /// # use crc_any::CRC;
1506 /// let mut crc = CRC::crc32mpeg2();
1507 /// crc.digest(b"123456789");
1508 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x0376E6E7\", &crc.to_string());")]
1509 /// ```
1510 #[inline]
1511 pub fn crc32mpeg2() -> CRC {
1512 CRC::CRCu32(CRCu32::crc32mpeg2())
1513 }
1514
1515 /// |Check|Poly|Init|Ref|XorOut|
1516 /// |---|---|---|---|---|
1517 /// |0x765E7680|0x04C11DB7|0x00000000|false|0xFFFFFFFF|
1518 ///
1519 /// ```
1520 /// # use crc_any::CRC;
1521 /// let mut crc = CRC::crc32posix();
1522 /// crc.digest(b"123456789");
1523 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x765E7680\", &crc.to_string());")]
1524 /// ```
1525 #[inline]
1526 pub fn crc32posix() -> CRC {
1527 CRC::CRCu32(CRCu32::crc32posix())
1528 }
1529
1530 /// |Check|Poly|Init|Ref|XorOut|
1531 /// |---|---|---|---|---|
1532 /// |0x3010BF7F|0x814141AB|0x00000000|false|0x00000000|
1533 ///
1534 /// ```
1535 /// # use crc_any::CRC;
1536 /// let mut crc = CRC::crc32q();
1537 /// crc.digest(b"123456789");
1538 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x3010BF7F\", &crc.to_string());")]
1539 /// ```
1540 #[inline]
1541 pub fn crc32q() -> CRC {
1542 CRC::CRCu32(CRCu32::crc32q())
1543 }
1544
1545 /// |Check|Poly|Init|Ref|XorOut|
1546 /// |---|---|---|---|---|
1547 /// |0x340BC6D9|0x04C11DB7 (rev: 0xEDB88320)|0x00000000|true|0x00000000|
1548 ///
1549 /// ```
1550 /// # use crc_any::CRC;
1551 /// let mut crc = CRC::crc32jamcrc();
1552 /// crc.digest(b"123456789");
1553 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x340BC6D9\", &crc.to_string());")]
1554 /// ```
1555 #[inline]
1556 pub fn crc32jamcrc() -> CRC {
1557 CRC::CRCu32(CRCu32::crc32jamcrc())
1558 }
1559
1560 /// |Check|Poly|Init|Ref|XorOut|
1561 /// |---|---|---|---|---|
1562 /// |0xBD0BE338|0x000000AF|0x00000000|false|0x00000000|
1563 ///
1564 /// ```
1565 /// # use crc_any::CRC;
1566 /// let mut crc = CRC::crc32xfer();
1567 /// crc.digest(b"123456789");
1568 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xBD0BE338\", &crc.to_string());")]
1569 /// ```
1570 #[inline]
1571 pub fn crc32xfer() -> CRC {
1572 CRC::CRCu32(CRCu32::crc32xfer())
1573 }
1574
1575 // TODO: CRC-40
1576
1577 /// |Check|Poly|Init|Ref|XorOut|
1578 /// |---|---|---|---|---|
1579 /// |0xD4164FC646|0x0004820009|0x0000000000|false|0xFFFFFFFFFF|
1580 ///
1581 /// ```
1582 /// # use crc_any::CRC;
1583 /// let mut crc = CRC::crc40gsm();
1584 /// crc.digest(b"123456789");
1585 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xD4164FC646\", &crc.to_string());")]
1586 /// ```
1587 #[inline]
1588 pub fn crc40gsm() -> CRC {
1589 CRC::CRCu64(CRCu64::crc40gsm())
1590 }
1591
1592 // TODO: CRC-64
1593
1594 /// |Check|Poly|Init|Ref|XorOut|
1595 /// |---|---|---|---|---|
1596 /// |0x6C40DF5F0B497347|0x42F0E1EBA9EA3693|0x0000000000000000|false|0x0000000000000000|
1597 ///
1598 /// ```
1599 /// # use crc_any::CRC;
1600 /// let mut crc = CRC::crc64();
1601 /// crc.digest(b"123456789");
1602 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x6C40DF5F0B497347\", &crc.to_string());")]
1603 /// ```
1604 #[inline]
1605 pub fn crc64() -> CRC {
1606 CRC::CRCu64(CRCu64::crc64())
1607 }
1608
1609 /// |Check|Poly|Init|Ref|XorOut|
1610 /// |---|---|---|---|---|
1611 /// |0xB90956C775A41001|0x000000000000001B (rev: 0xD800000000000000)|0xFFFFFFFFFFFFFFFF|true|0xFFFFFFFFFFFFFFFF|
1612 ///
1613 /// ```
1614 /// # use crc_any::CRC;
1615 /// let mut crc = CRC::crc64iso();
1616 /// crc.digest(b"123456789");
1617 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xB90956C775A41001\", &crc.to_string());")]
1618 /// ```
1619 #[inline]
1620 pub fn crc64iso() -> CRC {
1621 CRC::CRCu64(CRCu64::crc64iso())
1622 }
1623
1624 /// |Check|Poly|Init|Ref|XorOut|
1625 /// |---|---|---|---|---|
1626 /// |0x62EC59E3F1A4F00A|0x42F0E1EBA9EA3693|0xFFFFFFFFFFFFFFFF|false|0xFFFFFFFFFFFFFFFF|
1627 ///
1628 /// ```
1629 /// # use crc_any::CRC;
1630 /// let mut crc = CRC::crc64we();
1631 /// crc.digest(b"123456789");
1632 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0x62EC59E3F1A4F00A\", &crc.to_string());")]
1633 /// ```
1634 #[inline]
1635 pub fn crc64we() -> CRC {
1636 CRC::CRCu64(CRCu64::crc64we())
1637 }
1638
1639 /// |Check|Poly|Init|Ref|XorOut|
1640 /// |---|---|---|---|---|
1641 /// |0xE9C6D914C4B8D9CA|0xAD93D23594C935A9 (rev: 0x95AC9329AC4BC9B5)|0x0000000000000000|true|0x0000000000000000|
1642 ///
1643 /// ```
1644 /// # use crc_any::CRC;
1645 /// let mut crc = CRC::crc64jones();
1646 /// crc.digest(b"123456789");
1647 #[cfg_attr(feature = "alloc", doc = "assert_eq!(\"0xE9C6D914C4B8D9CA\", &crc.to_string());")]
1648 /// ```
1649 #[inline]
1650 pub fn crc64jones() -> CRC {
1651 CRC::CRCu64(CRCu64::crc64jones())
1652 }
1653}