Lua 5.5 library to generate 32-bits cyclic redundancy checks. Code includes four pre-generated lookup tables for six different methods.
Methods available:
- ISO-HDLC (default)
- ISCSI (with SSE 4.2)
- JAMCRC
- MPEG-2
- BZIP2
- CD-ROM-EDC
Binaries for AMD64 are available on Releases page. For x86, compile with gcc or use build.sh script. If on Windows, use MinGW/MSYS2 with CFLAGS and LFLAGS set to include and library paths, respectively.
env CFLAGS=-IC:/msys64/usr/local/include \
LFLAGS=-LC:/msys64/usr/local/bin ./build.shThen, require and call with a string to calculate its CRC. First and second arguments of calculate are strings, the latter is which method to use.
local crc32 = require("libluacrc32")
print(crc32.calculate("wrappem", "ISCSI"))
-- output: 969553473Note
If the Lua code above fails with module 'libluacrc32' not found on Windows, add package.cpath=".\\?.dll" one line before require or change your LUA_CPATH environment variable to include .\\?.dll.
| Key | Benchmark context |
|---|---|
| environment | single-core execution @ 2.10 GHz (amd64); Lua 5.5; library compiled with gcc -O3; target throughput of up to 128 MiB; ten retries per sample. |
| max. thoughput | method ISCSI with SSE 4.2 opcodes @ ~4GiB/s ± σ of ~65MiB/s. |
| min. thoughput | within pure Lua implementation @ ~4MiB/s ± σ of ~0.05MiB/s. |
