Git Product home page Git Product logo

excrc's Introduction

ExCRC

Quickly calculate CRC checksums in many variants using lookup tables.

ExCRC is implemented entirely in Elixir using recursion. There is a penalty for this: this library is much slower than if written in C or other pure binary NIF implementation. The advantage to using this library is that there are no extra dependencies on any platform and requires no external tools or compilation. If you need speed, use a NIF. If you want flexibility this library is a good choice.

There are variants of CRC so it's important to know which one you want to use. Refer to the CRC catalogue for full details. The key parameter in identifying the variant is the check value, the CRC checksum of the string 123456789.

Ported to Elixir from Lammert Bies' libCRC which seems to be the defacto implementation on StackExchange. Having looked at and tried porting many C libs, I found they didn't adapt well to functional recursion. All credit for the original work goes to Lammert.

It took me 3 days to convert 100 or so lines of C to 7 lines of Elixir :-)

I make no guarantees that this software works. Test it thoroughly before you use it in your heart-lung machine.

TL;DR

The API for this module is simple. Feed these a binary and it will poop out an integer CRC value computed with a variant of the CRC algorithm:

  • crc16ccitt/1 - CRC16/CCITT
  • crc16xmodem/1 - CRC16/XMODEM
  • crc16kermit/1 - CRC16/KERMIT

Installation

Available in Hex. Install the package by adding ex_crc to your list of dependencies in your mix.exs:

def deps do
  [
    {:ex_crc, "~> 1.0.0"}
  ]
end

Find the docs at https://hexdocs.pm/ex_crc.

Contributing

If your desired flavour isn't included, please feel free to add support and shoot me a pull request. Please include the 4 test cases from the libCRC test suite. If it proves conformity I'll merge it.

excrc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.