code: def crc16_ccitt(data, crc=0):
      
      tab = CRC16_CCITT_TAB  # minor optimization (now in locals)
      for byte in six.iterbytes(data):
          crc = (((crc << 8) & 0xff00) ^ tab[((crc >> 8) & 0xff) ^ byte])
      return crc & 0xffff
docs: Calculate the crc16 ccitt checksum of some data
  
      A starting crc value may be specified if desired.  The input data
      is expected to be a sequence of bytes (string) and the output
      is an integer in the range (0, 0xFFFF).  No packing is done to the
      resultant crc value.  To check the value a checksum, just pass in
      the data byes and checksum value.  If the data matches the checksum,
      then the resultant checksum from this function should be 0.