aboutsummaryrefslogtreecommitdiff
path: root/fw/crc.py
blob: 043c6e969844fd55315a3fc59b80369f3f496550 (plain)
1
2
3
4
5
6
7
8
import ctypes
import os
lib = ctypes.CDLL(os.path.join(os.path.dirname(__file__), '_crc.so'))
lib.crc32.restype = ctypes.c_uint32
def crc(data):
    if type(data) is not bytes:
        raise TypeError('This only works with bytes')
    return lib.crc32(data, len(data))