Implementation of CRC16 using polynomial 0x8005 - (X^16+X^15+X^2+1)
cyclic redundancy check
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents; on retrieval the calculation is repeated, and corrective action can be taken against presumed data corruption if the check values do not match.
[source:http://en.wikipedia.org/wiki/Cyclic_redundancy_check]
This class implements a basic CRC16 (17Bits) using polynomial 0x8005 (X^16 + X^15 + X^2 +1).
How to use this library
basic use of CRC 16t
char testdata[]= "123456789"; CRC16 *myCRC = new CRC16(); unsigned short resultCRC = myCRC->calculateCRC16(testdata,9); //9 is the length of the character array // pc.printf("%x",resultCRC);
CRC16.h
- Committer:
- EmLa
- Date:
- 2014-02-12
- Revision:
- 0:585ead300cab
File content as of revision 0:585ead300cab:
#ifndef CRC16_H #define CRC16_H class CRC16 { private: const unsigned int SHIFTER = 0x00FF; unsigned short crc16table[256]; public: unsigned short calculateCRC16(char input[], int lenght); CRC16(); ~CRC16(); }; #endif