const unsigned char crc8_tabl[]={0,56,34,345,67,89,343,108 ........ ........};/*str - указатель на начало массива crc которого считаемbyte - размер этого массива*/unsigned char crc8 (unsigned char *str,unsigned char byte){ unsigned char crc8=0; int index; while (byte){ crc8=crc8_tabl[crc8 ^ *str++]; --byte;}return crc8;}
unsigned char OutBuff[6]; OutBuff[0]='F'; OutBuff[1]=4; OutBuff[2]='G'; OutBuff[3]='S'; OutBuff[4]=56; OutBuff[5]=crc8(OutBuff,5);
uchar crc8(std::vector<uchar> array){ uchar ucrc8 = 0; std::vector<uchar>::iterator current = array.begin(); std::vector<uchar>::const_iterator last = array.end(); while (current != last) ucrc8 = crc8_tabl[ucrc8 ^ *current++]; return ucrc8;}