https://github.com/cfsamson/learning-crc32
A generic CRC algorithm with some basic tests
https://github.com/cfsamson/learning-crc32
Last synced: 2 months ago
JSON representation
A generic CRC algorithm with some basic tests
- Host: GitHub
- URL: https://github.com/cfsamson/learning-crc32
- Owner: cfsamson
- Created: 2021-03-03T00:52:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T21:10:07.000Z (about 4 years ago)
- Last Synced: 2025-02-09T22:22:34.626Z (4 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CRC - Cyclic Redundancy Check
Checksum to detect and/or correct errors in communications transmissions. This
algorithm is used to calculate the checksum in Ethernet frames amongst other
things.## Features
The algorithm is a general but to not add unneded runtime checks options to
reflect data/remainder is feature gated behind feature flags that needs to be
enabled:```text
--features reflect_data # reflects the data bits
--features reflect_remainder # reflects the remainder bits
--features reflect_all # reflects both data and remainder bits
```## Specifications
Some well known CRC spesifications:
|Features| CRC-CCITT| CRC-16 | CRC-32 |
|--------|----------|--------|--------|
|Width |16 bits|16 bits|32 bits|
|Truncated Polynominal|0x1021|0x8005|0x04C11DB7|
|Initial Remainder|0xFFFF|0x0000|0xFFFFFFFF|
|Final XOR value|0x0000|0x0000|0xFFFFFFFF|
|Reflect data?|No|Yes|Yes|
|Reflect remainder?|No|Yes|Yes|
|Check value*|0x29B1|0xBB3D|0xCBF43926|\* Check value is the expected CRC with the input data "123456789" (see tests)
## Further reading
https://barrgroup.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
## Warning
This is a learning project so the code has a lot of comments and debug print
statements. Do not use this for anything else than learning.