aboutsummaryrefslogtreecommitdiff
path: root/fw/crc.py
diff options
context:
space:
mode:
Diffstat (limited to 'fw/crc.py')
-rw-r--r--fw/crc.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/fw/crc.py b/fw/crc.py
new file mode 100644
index 0000000..043c6e9
--- /dev/null
+++ b/fw/crc.py
@@ -0,0 +1,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))