title: Calculating CRC16 in Python
body: <p>I'm trying to evaluate appropriate checksum based on <strong>CRC-16</strong> algorithm using <a href="https://pypi.python.org/pypi/crcmod" rel="nofollow">crcmod</a> Python module and 2.7 version of Python interpreter. The checksum parameters are:</p>
  
  <ul>
  <li>CRC order: 16  </li>
  <li>CRC polynomial: 0x8005  </li>
  <li>Inital value: 0xFFFF  </li>
  <li>Final value: 0x0000  </li>
  <li>Direct: True  </li>
  </ul>
  
  <p>Code:</p>
  
  <pre><code>crc16 = crcmod.mkCrcFun(0x18005, rev=False, initCrc=0xFFFF, xorOut=0x0000)
  print hex(crc16(str(int(0x5A0001))))
  </code></pre>
  
  <p>and for the input <code>0x5A0001</code> it prints <code>0x7E16</code> while I should get something like <code>0xCE0A</code>.</p>
  
  <p>I checked on <a href="http://www.lokker.net/Java/crc/CRCcalculation2.htm" rel="nofollow">http://www.lokker.net/Java/crc/CRCcalculation2.htm</a> and the computed value is <code>0xACE</code> which is correct (with respect to the order).</p>