Skip to content

About

Lua 5.5 library to generate 32-bits cyclic redundancy checks.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

Repository files navigation

libluacrc32

Static Badge GitHub Release GitHub License Static Badge

Lua 5.5 library to generate 32-bits cyclic redundancy checks. Code includes four pre-generated lookup tables for six different methods.

Methods available:

  1. ISO-HDLC (default)
  2. ISCSI (with SSE 4.2)
  3. JAMCRC
  4. MPEG-2
  5. BZIP2
  6. CD-ROM-EDC

Usage

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.sh

Then, 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: 969553473

Note

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.

Benchmark

benchmark figure

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.

Further reading

  1. Catalogue of parametrised CRC algorithms with 17 or more bits.

About

Lua 5.5 library to generate 32-bits cyclic redundancy checks.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages