Reputation: 229
When I read this link: http://docs.oracle.com/javase/7/docs/api/java/util/zip/CRC32.html There is method to get CRC32 value from array of bytes. However, when I send this CRC32ed value to receiver, how can receiver check if this value is valid?
Upvotes: 1
Views: 2029
Reputation: 881113
The idea is that the receiver will run the same algorithm on the data you sent through, and it should get the same CRC32 value. If not, the data (or CRC) has been corrupted somehow.
In other words, let's say your payload is "Pax is an incredibly handsome guy"
and you calculate the CRC as 42.
You send through both that payload and the CRC to the receiving end and it performs the same actions on the payload, also coming up with 42.
That means the content of that payload is correct. But not necessarily the veracity :-)
That's what CRC stands for, cyclic redundancy check.
Keep in mind that CRCs tend to be effective against accidental damage to payload but, unless there's some secret information being used to generate the check, it can be faked.
Upvotes: 4