{"id":18759002,"url":"https://github.com/tattdcodemonkey/crc","last_synced_at":"2025-08-20T10:31:11.757Z","repository":{"id":44883918,"uuid":"46834318","full_name":"TattdCodeMonkey/crc","owner":"TattdCodeMonkey","description":"CRC library in elixir","archived":false,"fork":false,"pushed_at":"2023-06-23T16:29:00.000Z","size":388,"stargazers_count":26,"open_issues_count":6,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-15T16:18:57.263Z","etag":null,"topics":["crc","elixir","nerves"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TattdCodeMonkey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-25T03:12:36.000Z","updated_at":"2024-06-10T21:06:17.000Z","dependencies_parsed_at":"2024-06-19T10:02:06.276Z","dependency_job_id":"13b17457-3961-4f1c-9e20-a99ae57fc1aa","html_url":"https://github.com/TattdCodeMonkey/crc","commit_stats":{"total_commits":82,"total_committers":17,"mean_commits":4.823529411764706,"dds":0.6341463414634146,"last_synced_commit":"1460ab0638fe2265cf4e66cdf76d54914bd6723a"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fcrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fcrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fcrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fcrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TattdCodeMonkey","download_url":"https://codeload.github.com/TattdCodeMonkey/crc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230415317,"owners_count":18222158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crc","elixir","nerves"],"created_at":"2024-11-07T17:48:45.474Z","updated_at":"2024-12-19T10:08:39.402Z","avatar_url":"https://github.com/TattdCodeMonkey.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CRC\n\n[![Module Version](https://img.shields.io/hexpm/v/crc.svg)](https://hex.pm/packages/crc)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/crc/)\n[![Total Download](https://img.shields.io/hexpm/dt/crc.svg)](https://hex.pm/packages/crc)\n[![License](https://img.shields.io/hexpm/l/crc.svg)](https://github.com/TattdCodeMonkey/crc/blob/master/LICENSE)\n[![Last Updated](https://img.shields.io/github/last-commit/TattdCodeMonkey/crc.svg)](https://github.com/TattdCodeMonkey/crc/commits/master)\n\nThis module is used to calculate CRC (Cyclic Redundancy Check) values for binary data. It uses NIF functions written in C to iterate over the given binary calculating the CRC checksum value. The NIFs are written to report their time slice usage and will not interfere with the schedulers.\n\n## Installation\n\n### Elixir\n\nAdd `:crc` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:crc, \"~\u003e 0.10\"}\n  ]\nend\n```\n\n### Erlang\n\nAdd `crc` to your `rebar.config`:\n\n```erlang\n{deps, [\n  {crc, \"0.10.5\"}\n]}.\n```\n\nOr `erlang.mk`:\n\n```erlang\ndep_crc = hex 0.10.5\n```\n\n## Supported algorithms (models)\n\nRun `CRC.list/0` to get a full list of all pre-defined models or `CRC.list/1` with a filter to search for a pre-defined model.\n\n## Usage\n\nTo calculate a CRC-16 X-Modem checksum for the binary `\u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e` using the pre-defined model:\n\n```elixir\niex\u003e CRC.crc(:crc_16_xmodem, \u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e)\n31763\n\niex\u003e CRC.calculate(\u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e, :crc_16_xmodem)\n31763\n```\n\nOr you can create a model at runtime, this can be done with a map:\n\n```elixir\niex\u003e CRC.crc(\n  %{\n    width: 16,\n    poly: 0x1021,\n    init: 0x00,\n    refin: false,\n    refout: false,\n    xorout: 0x00\n  },\n  \u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e\n)\n31763\niex\u003e CRC.calculate(\n  \u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e,\n  %{\n    width: 16,\n    poly: 0x1021,\n    init: 0x00,\n    refin: false,\n    refout: false,\n    xorout: 0x00\n  }\n)\n31763\n```\n\nOr you can extend one of the pre-defined models:\n\n```elixir\niex\u003e CRC.crc(\n  %{\n    extend: :crc_16_xmodem,\n    init: 0x00,\n  },\n  \u003c\u003c1,2,3,4,5,4,3,2,1\u003e\u003e\n)\n31763\n```\n\n`CRC.crc_init/1` is used to create a resource and be used to do partial updates to a calculation that is then finalized later:\n\n```elixir\niex\u003e resource = CRC.crc_init(:crc_16_xmodem)\n#Reference\u003cx.x.x.x\u003e\n\niex\u003e resource2 = CRC.crc_update(resource, \u003c\u003c1, 2, 3, 4, 5\u003e\u003e)\n#Reference\u003cy.y.y.y\u003e\n\niex\u003e resource3 = CRC.crc_update(resource2, \u003c\u003c4, 3, 2, 1\u003e\u003e)\n#Reference\u003cz.z.z.z\u003e\n\niex\u003e CRC.crc_final(resource3)\n31763\n```\n\nThis could be useful to calculate a CRC for a larger binary that you are receiving asynchronously.\n\n## Tests\n\nCRC implementations have been tested against these online calculators to validate their correctness to the best of our ability.\n\n-  https://www.lammertbies.nl/comm/info/crc-calculation.html\n-  http://www.sunshine2k.de/coding/javascript/crc/crc_js.html\n\nThere are also two property tests that can use [PyCRC](https://github.com/tpircher/pycrc) or [CRC RevEng](https://sourceforge.net/projects/reveng/) if installed and configured locally.\n\n```bash\n$ export PYCRC_BIN=~/pycrc-0.9.1/pycrc.py\n$ export REVENG_BIN=~/reveng-1.5.2/reveng\n$ mix test\n```\n\nPyCRC is used as a part of the TravisCI test suite.\n\n## Copyright and License\n\nCopyright (c) 2015 Rodney Norris\n\nCRC is released under the MIT License. See the [LICENSE.md](./LICENSE.md) file\nfor further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattdcodemonkey%2Fcrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattdcodemonkey%2Fcrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattdcodemonkey%2Fcrc/lists"}