Nicoretti / crc

Pure Python CRC library
https://nicoretti.github.io/crc/
BSD 2-Clause "Simplified" License
53 stars 13 forks source link

🐞 Return of digest() is not stable #151

Closed IsaacDynamo closed 7 months ago

IsaacDynamo commented 7 months ago

Summary

Multiple calls to digest() don't return the same answers.

Reproducing the Issue

>>> import crc
>>> r = crc.Register(crc.Crc8.BLUETOOTH)
>>> r.init()
>>> r.update(b"Hello World!")
138
>>> r.digest()
81
>>> r.digest()
138
>>> r.digest()
81

Expected Behaviour

Expected multiple calls to digest() to return the same value.

Actual Behaviour

Return value flip-flops between two values.

Root Cause (optional)

I think it is caused by in-place reverse in digest(), L256-L257

Nicoretti commented 7 months ago

Hi @IsaacDynamo,

nice find 👍! Root cause also seems to be spot on. Thanks for reporting this ❤️, I'll try to address this and provide a release as soon as possible.

best Nico

Nicoretti commented 7 months ago

https://github.com/Nicoretti/crc/releases/tag/6.1.2