CRC is short for Cyclic Redundancy Check.
A cyclic redundancy check (CRC) is a type of function that takes as input a data stream of any length and produces as output a value of a certain fixed size. The term CRC is often used to denote either the function or the function's output. A CRC can be used in the same way as a checksum to detect accidental alteration of data during transmission or storage. CRCs are popular because they are simple to implement in binary hardware, are easy to analyze mathematically, and are particularly good at detecting common errors caused by noise in transmission channels. The CRC was invented by W. Wesley Peterson, and published in his 1961 paper.
CRC的中文意思是循环冗余校验。
下面是CRC16的C语言实现:
int CRC16( char *p, int len )
{
register unsigned char l, h, t;
l=h=0xff;
for( int i=0; i<len; i++ )
{
h^=p[i];
h^=h>>4;
t=h;
h=l;
l=t;
t=(l<<4) | (l>>4);
h^=((t<<2) | (t>>6)) & 0x1f;
h^=t&0xf0;
l^=((t<<1) | (t>>7)) & 0xe0;
}
return ((int)h<<8) | l;
}
The following link can help you getting detail information of CRC: http://en.wikipedia.org/wiki/Cyclic_redundancy_check