问题
Why we need to invert crc? In which cases we need to do this? (invert mean crc = ~crc
)
Is it defence from zero cases (when whole message is consists of zeros)?
How it helps in this case?
回答1:
You mean invert, or take the one's complement. (Reverse would mean swapping the order of the bits, undoing a CRC calculation, or reverse-engineering the CRC parameters.)
That is done when the CRC parameters are defined that way. See this list of CRCs, where those with xorout
defined as all 1's are inverting the CRC before return.
A common example is when the initial register contents, init
is also all 1's, so the final xorout
then makes the CRC of an empty string zero. The init
being non-zero is how you "defend" against the all-zeros message case, which assures that every zero changes the CRC. The xorout
then just provides the nicety of a CRC of an empty message being zero. There are CRC definitions there with zero xorout
(no invert or exclusive-or at the end), but a non-zero init
, which provides that defense as well.
来源:https://stackoverflow.com/questions/39385468/why-we-need-to-invert-crc-in-which-cases-we-need-to-do-this