2

I'm trying to find an efficient way to calculate the CRC16 polynomial using the base value and the CRC16 output.
An example to be more clear:

y = CRC16(x)

How can I find the polynomial used by CRC16 function to evaluate y?
I'm using C and Python to create some executable (for test purposes).

neoben
  • 743
  • 12
  • 30
  • I'd start by working with the simplest possible input, an empty string or one consisting of a single zero byte. – Mark Ransom Apr 16 '15 at 16:41
  • There are only 32K possible values for a 17-bit number with both high and low bits set. Why are you bringing up efficiency? – stark Apr 16 '15 at 16:53
  • Are you saying you have access to a function `CRC16()`, and you would like to re-implement that function? If so, please provide the CRC returned by that function for the nine bytes (in ASCII): "123456789". – Mark Adler Apr 17 '15 at 04:54
  • I have 2 bytes that are the output of the CRC16 function and then I have the original data. I'm trying to understand what kind of polynomial is used by the CRC function to obtain that specific 2 bytes starting from that specific original data. – neoben Apr 17 '15 at 07:43

2 Answers2

0

The list of the polynomials for CRC checking can be found here:

http://en.wikipedia.org/wiki/Polynomial_representations_of_cyclic_redundancy_checks

In particular, you probably want the polynomial CRC-16-ANSI

enter image description here

Hooked
  • 84,485
  • 43
  • 192
  • 261
  • i think CRC-16-CCITT is used more, CCITT: Comité Consultatif International Téléphonique et Télégraphique The International Telegraph and Telephone Consultative Committe, now ITU-T – computingfreak Oct 25 '16 at 05:58
0

Lammert Bies has an excellent page with references and C libraries for different methods for CRC-16.

Mainly, it contains an online calculator that you can use to immediately see if what you want is one of the well know methods.

If it is, the C libraries give immediately an optimised implementation of a CRC calculator, and they can easily be translated in Python. You will find an example for CRC-CCITT XMODEM variant in this other answer from mine

Community
  • 1
  • 1
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
  • I know this is not far from a link only answer, but I really do not know how to do it differently : first link **has** to be a link since it is an online calculator, and second is just an example for previous explaination. – Serge Ballesta Apr 16 '15 at 18:02