Comments (2)
Hi @FranckN-maker,
thanks for reporting. Apparently the snippet below works just fine.
from crc import Configuration, Register
config = Configuration(
width=16,
polynomial =0x1021,
init_value=0xffff,
final_xor_value=0xffff,
reverse_input=False,
reverse_output=False,
)
reg = Register(config)
expected = 0x1B18
data = [18, 65, 116, 210, 22, 0, 0, 245, 121, 26, 250, 44, 48, 41, 135, 240, 127, 165, 123, 0, 96]
reg.init()
reg.update(data)
assert expected == reg.digest()
That said, it looks like you have found a bug in the convenience wrapper Calculator
.
from crc import Configuration, Calculator
config = Configuration(
width=16,
polynomial =0x1021,
init_value=0xffff,
final_xor_value=0xffff,
reverse_input=False,
reverse_output=False,
)
calc = Calculator(config)
expected = 0x1B18
data = [18, 65, 116, 210, 22, 0, 0, 245, 121, 26, 250, 44, 48, 41, 135, 240, 127, 165, 123, 0, 96]
assert expected == calculator.checksum(data)
yields the wrong checksum.
Recommendation
Until #113 have been fixed, I recommend you use the register API (TablesBasedRegister
, Register
).
best
Nico
from crc.
Issue is closed, because the underlying problem is now tracked in #113.
If the provided recommendation is not sufficient or not leading to a resolution, please reopen the issue.
from crc.
Related Issues (20)
- mypy error: Skipping analyzing "crc": [...] missing library stubs or py.typed marker HOT 8
- π Invalid checksum is calculated when using `Calculator` instead of `Register` classes HOT 10
- Crc8.SAEJ1850 has wrong `init_value` and `final_xor_value` HOT 2
- π Readme update HOT 2
- πPredefined `Crc16.CCITT` is confusing HOT 4
- π§ Refactor CRC-16 Configuration Naming and Expand Variants HOT 4
- π Return of digest() is not stable HOT 2
- π My project on github uses crc. When I ran my tests I got an error relating to CCITT HOT 1
- Inconsistent CRC result for different input type HOT 9
- Add support for arbitrary input and output bit widths HOT 7
- Automate pypi deployment with GitHub action(s) HOT 1
- Automate code coverage reporting with GitHub Actions
- lookup table generation output is wrong HOT 1
- file input handling could be better HOT 1
- Create a pypi release containing the latest changes HOT 1
- Implement Reverse Input/Output Lookup Table when running table_based HOT 7
- Add missing __version__ attribute HOT 2
- "poly" should be "polynomial" in example HOT 1
- Add 16bit MODBUS config HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crc.