EvilCrc32c (evil_crc32c v0.1.0)

"Evil" version of the crc32c algorithm. It uses the bitwise arithmetic used in javascript, i.e. operands are converted to i32

Link to this section Summary

Functions

Calculate the CRC.

Calculate the CRC. Raises an Argument error if data is not binary

Link to this section Functions

Link to this function

calc(data, binary \\ true)

@spec calc(binary(), boolean()) ::
  {:ok, integer() | binary()} | {:error, :not_binary_data}

Calculate the CRC.

Expect binary data.

Examples

iex> EvilCrc32c.calc(<<1, 2, 3, 4>>)
{:ok, <<244, 140, 48, 41>>}

iex> EvilCrc32c.calc(5)
{:error, :not_binary_data}

iex> EvilCrc32c.calc("hello", false)
{:ok, -1703822516}

iex> EvilCrc32c.calc("hello", true)
{:ok, <<76, 187, 113, 154>>}
Link to this function

calc!(data, binary \\ true)

@spec calc!(binary(), boolean()) :: integer() | binary() | no_return()

Calculate the CRC. Raises an Argument error if data is not binary

Expect binary data.

Examples

iex> EvilCrc32c.calc!(<<1, 2, 3, 4>>)
<<244, 140, 48, 41>>

iex> EvilCrc32c.calc!("hello", false)
-1703822516

iex> EvilCrc32c.calc!("hello", true)
<<76, 187, 113, 154>>