title: CRC-16 and CRC-32 Checks
body: <p>I need help trying to verify CRC-16 values (also need help with CRC-32 values). I tried to sit down and understand how CRC works but I am drawing a blank. </p>
  
  <p>My first problem is when trying to use an online calculator for calculating the message "<code>BD001325E032091B94C412AC</code>" into <strong>CRC16 = 12AC</strong>. The documentation states that the last two octets are the CRC16 value, so I am inputting "<code>BD001325E032091B94C4</code>" into the site <a href="http://www.lammertbies.nl/comm/info/crc-calculation.html" rel="nofollow">http://www.lammertbies.nl/comm/info/crc-calculation.html</a> and receive 5A90 as the result instead of 12AC.</p>
  
  <p><strong>Does anybody know why these values are different and where I can find code for how to calculate CRC16 and CRC32 values (I plan to later learn how to do this but times doesn't allow right now)?</strong></p>
  
  <p>Some more messages are as following:</p>
  
  <pre><code>16000040FFFFFFFF00015FCB  
  3C00003144010405E57022C7  
  BA00001144010101B970F0ED  
  3900010101390401B3049FF1  
  09900C800000000000008CF3  
  8590000000000000000035F7  
  00900259025902590259EBC9  
  0200002B00080191014BF5A2  
  BB0000BEE0014401B970E51E  
  3D000322D0320A2510A263A0  
  2C0001440000D60000D65E54
  </code></pre>
  
  <p>--Edit--</p>
  
  <p>I have included more information. The documentation I was referencing is TIA-102.BAAA-A (from the TIA standard). The following is what the documentation states (trying to avoid copyright infringement as much as possible):</p>
  
  <blockquote>
    <p>The Last Block in a packet comprises several octets of user information and / or
    pad octets, followed by a 4-octet CRC parity check. This is referred to as the
    packet CRC.</p>
    
    <p>The packet CRC is a 4-octet cyclic redundancy check coded over all of the data
    octets included in the Intermediate Blocks and the octets of user information of
    the Last Block. The specific calculation is as follows.</p>
    
    <p>Let k be the total number of user information and pad bits over which the packet
    CRC is to be calculated. Consider the k message bits as the coefficients of a
    polynomial M(x) of degree k–1, associating the MSB of the zero-th message
    octet with x^k–1 and the LSB of the last message octet with x^0. Define the
    generator polynomial, GM(x), and the inversion polynomial, IM(x).</p>
    
    <p>GM(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 +
    x^4 + x^2 + x + 1</p>
    
    <p>IM(x) = x^31 + x^30 + x^29 + ... + x^2 + x +1</p>
    
    <p>The packet CRC polynomial, FM(x), is then computed from the following formula.</p>
    
    <p>FM(x) = ( x^32 M(x) mod GM(x) ) + IM(x) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modulo 2, i.e., in GF(2)</p>
    
    <p>The coefficients of FM(x) are placed in the CRC field with the MSB of the zero-th
    octet of the CRC corresponding to x^31 and the LSB of the third octet of the CRC
    corresponding to x^0.</p>
  </blockquote>
  
  <p>In the above quote, I have put <code>^</code> to show powers as the formatting didn't stay the same when quoted. I'm not sure what goes to what but does this help?</p>