Crate crc

Source
Expand description

§crc

Rust implementation of CRC.

§Examples

Using a well-known algorithm:

const X25: crc::Crc<u16> = crc::Crc::<u16>::new(&crc::CRC_16_IBM_SDLC);
assert_eq!(X25.checksum(b"123456789"), 0x906e);

Using a custom algorithm:

const CUSTOM_ALG: crc::Algorithm<u16> = crc::Algorithm {
    width: 16,
    poly: 0x8005,
    init: 0xffff,
    refin: false,
    refout: false,
    xorout: 0x0000,
    check: 0xaee7,
    residue: 0x0000
};
let crc = crc::Crc::<u16>::new(&CUSTOM_ALG);
let mut digest = crc.digest();
digest.update(b"123456789");
assert_eq!(digest.finalize(), 0xaee7);

Structs§

Algorithm
This struct describes a CRC algorithm using the fields specified by the Catalogue of parametrised CRC algorithms.
Crc
Crc instance with a specific width, algorithm, and implementation.
Digest
Table
A table-based implementation of the CRC algorithm, with L lanes. The number of entries in the lookup table is L * 256.

Constants§

CRC_3_GSM
CRC_3_ROHC
CRC_4_G_704
CRC_4_INTERLAKEN
CRC_5_EPC_C1G2
CRC_5_G_704
CRC_5_USB
CRC_6_CDMA2000_A
CRC_6_CDMA2000_B
CRC_6_DARC
CRC_6_GSM
CRC_6_G_704
CRC_7_MMC
CRC_7_ROHC
CRC_7_UMTS
CRC_8_AUTOSAR
CRC_8_BLUETOOTH
CRC_8_CDMA2000
CRC_8_DARC
CRC_8_DVB_S2
CRC_8_GSM_A
CRC_8_GSM_B
CRC_8_HITAG
CRC_8_I_432_1
CRC_8_I_CODE
CRC_8_LTE
CRC_8_MAXIM_DOW
CRC_8_MIFARE_MAD
CRC_8_NRSC_5
CRC_8_OPENSAFETY
CRC_8_ROHC
CRC_8_SAE_J1850
CRC_8_SMBUS
CRC_8_TECH_3250
CRC_8_WCDMA
CRC_10_ATM
CRC_10_CDMA2000
CRC_10_GSM
CRC_11_FLEXRAY
CRC_11_UMTS
CRC_12_CDMA2000
CRC_12_DECT
CRC_12_GSM
CRC_12_UMTS
CRC_13_BBC
CRC_14_DARC
CRC_14_GSM
CRC_15_CAN
CRC_15_MPT1327
CRC_16_ARC
CRC_16_CDMA2000
CRC_16_CMS
CRC_16_DDS_110
CRC_16_DECT_R
CRC_16_DECT_X
CRC_16_DNP
CRC_16_EN_13757
CRC_16_GENIBUS
CRC_16_GSM
CRC_16_IBM_3740
CRC_16_IBM_SDLC
CRC_16_ISO_IEC_14443_3_A
CRC_16_KERMIT
CRC_16_LJ1200
CRC_16_M17
CRC_16_MAXIM_DOW
CRC_16_MCRF4XX
CRC_16_MODBUS
CRC_16_NRSC_5
CRC_16_OPENSAFETY_A
CRC_16_OPENSAFETY_B
CRC_16_PROFIBUS
CRC_16_RIELLO
CRC_16_SPI_FUJITSU
CRC_16_T10_DIF
CRC_16_TELEDISK
CRC_16_TMS37157
CRC_16_UMTS
CRC_16_USB
CRC_16_XMODEM
CRC_17_CAN_FD
CRC_21_CAN_FD
CRC_24_BLE
CRC_24_FLEXRAY_A
CRC_24_FLEXRAY_B
CRC_24_INTERLAKEN
CRC_24_LTE_A
CRC_24_LTE_B
CRC_24_OPENPGP
CRC_24_OS_9
CRC_30_CDMA
CRC_31_PHILIPS
CRC_32_AIXM
CRC_32_AUTOSAR
CRC_32_BASE91_D
CRC_32_BZIP2
CRC_32_CD_ROM_EDC
CRC_32_CKSUM
CRC_32_ISCSI
CRC_32_ISO_HDLC
CRC_32_JAMCRC
CRC_32_MEF
CRC_32_MPEG_2
CRC_32_XFER
CRC_40_GSM
CRC_64_ECMA_182
CRC_64_GO_ISO
CRC_64_MS
CRC_64_REDIS
CRC_64_WE
CRC_64_XZ
CRC_82_DARC

Traits§

Implementation
A trait for CRC implementations.
Width

Type Aliases§

NoTable
An implementation of the CRC algorithm with no lookup table.