(data)
return rem ^ 0xffff
Calculate 16-bit CRC-16-CCITT for data.
Calculate 16-bit CRC-16-CCITT for data.
Calculate 16 - bit CRC - 16 - CCITT for data .
def crc(data):
    """Calculate 16-bit CRC-16-CCITT for data."""
    # see http://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
    # for a lookup table version, see e.g. WAV2CAS v1.3 for Poisk PC. by Tronix (C) 2013
    # however, speed is not critical for this function
    rem = 0xffff
    for d in bytearray(data):
        rem ^= d << 8
        for _ in range(8):
            rem <<= 1
            if rem & 0x10000:
                rem ^= 0x1021
            rem &= 0xffff
    return rem ^ 0xffff
def crc ( data ) : # see http://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks # for a lookup table version, see e.g. WAV2CAS v1.3 for Poisk PC. by Tronix (C) 2013 # however, speed is not critical for this function rem = 0xffff for d in bytearray ( data ) : rem ^= d << 8 for _ in range ( 8 ) : rem <<= 1 if rem & 0x10000 : rem ^= 0x1021 rem &= 0xffff return rem ^ 0xffff