Expand description
Frame checksums.
The Checksum trait describes an integrity check that produces a fixed
number of bytes. Three common CRCs are built in, implemented locally with
const-generated lookup tables (slice-by-8 for the CRC-32 variants) so
the crate stays dependency-free:
| Type | Algorithm (catalogue name) | Width | Typical use |
|---|---|---|---|
Crc16CcittFalse | CRC-16/IBM-3740 (a.k.a. CRC-16/CCITT-FALSE) | 2 bytes | Serial links, Bluetooth, many embedded protocols |
Crc32 | CRC-32/ISO-HDLC (IEEE 802.3, zlib, PNG) | 4 bytes | Ethernet, gzip, general purpose |
Crc32c | CRC-32/ISCSI (Castagnoli) | 4 bytes | iSCSI, SCTP, ext4, Kafka record batches |
Pair a checksum with any framer through
Checksummed. Implement Checksum
yourself to plug in a different algorithm (for example a hardware CRC
unit on a microcontroller).
A CRC detects accidental corruption. It is not a MAC: anyone can compute a valid CRC for forged data. Use an authenticated cipher or a keyed MAC when the peer is adversarial.
Structs§
- Crc32
- CRC-32/ISO-HDLC, the CRC-32 of IEEE 802.3, zlib, gzip, and PNG.
- Crc16
Ccitt False - CRC-16/IBM-3740, widely known as CRC-16/CCITT-FALSE.
- Crc32c
- CRC-32/ISCSI (Castagnoli), used by iSCSI, SCTP, ext4, and Kafka.
Traits§
- Checksum
- An integrity check over a byte slice that yields
Checksum::LENbytes.
Functions§
- crc32
- Compute CRC-32/ISO-HDLC (IEEE) of
data. - crc16_
ccitt_ false - Compute CRC-16/IBM-3740 (CRC-16/CCITT-FALSE) of
data. - crc32c
- Compute CRC-32/ISCSI (Castagnoli) of
data.