GithubHelp home page GithubHelp logo

isabella232 / node-crc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tritondatacenter/node-crc

0.0 0.0 0.0 368 KB

Blazingly fast CRC implementations for node.js and browser

License: MIT License

JavaScript 34.66% Python 59.18% Makefile 0.21% Shell 3.02% C 2.94%

node-crc's Introduction

crc

The module for calculating Cyclic Redundancy Check (CRC) for Node.js and the Browser.

Features

  • Full test suite comparing values against reference pycrc implementation.
  • Pure JavaScript implementation, no dependencies.
  • ES6 modules.
  • Provides CRC tables for optimized calculations.
  • Provides support for the following CRC algorithms:
    • CRC1 (crc1)
    • CRC8 (crc8)
    • CRC8 1-Wire (crc81wire)
    • CRC16 (crc16)
    • CRC16 CCITT (crc16ccitt)
    • CRC16 Modbus (crc16modbus)
    • CRC16 Kermit (crc16kermit)
    • CRC16 XModem (crc16xmodem)
    • CRC24 (crc24)
    • CRC32 (crc32)
    • CRCJAM (crcjam)

Installation

npm install crc

Usage

Calculate a CRC32 (recommended way):

import crc32 from 'crc/crc32';
crc32('hello').toString(16);
// "3610a686"

Import everything (this may bloat bundle size):

import crc from 'crc';
crc.crc32('hello').toString(16);
// "3610a686"

Or use CommonJS (compatability mode, no longer recommended):

const { crc32 } = require('crc');
crc32('hello').toString(16);
// "3610a686"

Calculate a CRC32 of a file:

crc32(fs.readFileSync('README.md', 'utf8')).toString(16);
// "127ad531"

Or using a Buffer:

crc32(fs.readFileSync('README.md', 'utf8')).toString(16);
// "127ad531"

Incrementally calculate a CRC32:

value = crc.crc32('one');
value = crc.crc32('two', value);
value = crc.crc32('three', value);
value.toString(16);
// "9e1c092"

Important: Node >= 6.3.0 < 6.9.2

There's was a bug in Node #9342 that affected CRC calculation if Buffer.split() is used (see issue discussion for details). This affected all version starting from 6.3.0 up to but not including 6.9.2. The patch #9341 was released in 6.9.2. If you are upgrading and seeing odd CRC calculation mismatches, this might be the reason.

Running tests

npm test

Thanks!

pycrc library is which the source of all of the CRC tables.

License

The MIT License (MIT)

Copyright (c) 2014 Alex Gorbatchev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-crc's People

Contributors

alexgorbatchev avatar alunny avatar chris-jamieson avatar gmethvin avatar huyx avatar ivansanchez avatar junosuarez avatar larshp avatar lmommaerts avatar mithgol avatar onip avatar overra avatar phra avatar ssproessig avatar thebadger412 avatar tj avatar underbluewaters avatar zamiang 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.