https://github.com/oagoulart/libluacrc32
Lua library to generate 32-bits cyclic redundancy checks.
https://github.com/oagoulart/libluacrc32
crc32 iso13239 lua lua-library sse42
Last synced: 2 months ago
JSON representation
Lua library to generate 32-bits cyclic redundancy checks.
- Host: GitHub
- URL: https://github.com/oagoulart/libluacrc32
- Owner: oAGoulart
- License: ms-rl
- Created: 2025-07-23T22:51:55.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-08-01T17:06:21.000Z (2 months ago)
- Last Synced: 2025-08-01T19:25:49.889Z (2 months ago)
- Topics: crc32, iso13239, lua, lua-library, sse42
- Language: C
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libluacrc32
[](https://www.iso.org/standard/37010.html)
[](https://github.com/oAGoulart/libluacrc32/releases)
[](https://github.com/oAGoulart/libluacrc32/tree/master?tab=MS-RL-1-ov-file)
[](https://www.lua.org/download.html)Lua 5.4 library to generate 32-bits cyclic redundancy checks. Code includes four pre-generated lookup tables for six different methods.
**Methods available:**
1. ISO-HDLC
1. ISCSI (supports SSE 4.2; aprox. 10x faster)
1. JAMCRC
1. MPEG-2
1. BZIP2
1. CD-ROM-EDC## Usage
Binaries for AMD64 are available on [Releases](https://github.com/oAGoulart/libluacrc32/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.
```sh
env CFLAGS=-IC:/Users/a_gou/scoop/apps/lua/5.4.7-2/include \
LFLAGS=-LC:/Users/a_gou/scoop/apps/lua/5.4.7-2/bin ./build.sh
```**NOTE:** If you want to use MSVC, you are on your own, sorry.
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.
```lua
local crc32 = require("libluacrc32")print(crc32.calculate("wrappem", "ISO-HDLC"))
```**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`.
## Further reading
1. [Catalogue of parametrised CRC algorithms with 17 or more bits](https://reveng.sourceforge.io/crc-catalogue/17plus.htm).