talira

crc (Elixir)

CRC checksums for binary data in Elixir and Erlang

open sourceMITfree

crc calculates CRC (cyclic redundancy check) values for binary data in Elixir and Erlang, using NIFs written in C that report their time-slice usage so they don't block the schedulers. It ships many pre-defined models such as CRC-16 X-Modem, lets you define or extend a model at runtime with a map, and supports incremental calculations that you finalise later.

Problems it solves

  • compute a CRC-16 checksum of a binary in Elixir
  • verify the checksum on frames from a serial device or binary protocol in Erlang
  • calculate a CRC over a stream of chunks without holding it all in memory

Features

  • pre-defined CRC models, listed with CRC.list/0 and CRC.list/1
  • custom models defined at runtime, or extended from a pre-defined one
  • incremental calculation with crc_init, updated in parts and finalised later
  • C NIFs that report time-slice usage so they don't interfere with the schedulers
  • usable from Mix, rebar3 and erlang.mk

Limitations

  • Builds its NIFs from C source, so installing it needs a C compiler and make1