Git Product home page Git Product logo

bitcrc_python's Introduction

bitcrc

Perform CRC with arbitrary order polynomials on data with an arbitrary length accelerated with lookup tables.

Why?

  1. You need to support a polynomial that's not a multiple of 8 bits long.
  2. You need to support data that's not a multiple of 8 bits long.
  3. It needs to be relatively fast.

How?

You can use the BitCrc class directly

from bitcrc_python import BitCrc

# Our polynomial is 0x1021, 16 bits long
crc = BitCrc(16, 0x1021, initialValue=0xFFFF, xorOut=0xFFFF)
checksum = crc.generate("Hello World")
assert(checksum == 0x4D25)

Or drop the library in as a replacement for crcmod

from bitcrc_python import crcmod

# Instead of specifying the length with crcmod
#   you just need to include the leading bit.
crc = crcmod.mkCrcFun(0x11021, initCrc=0xFFFF)
checksum = crc("Hello world")
assert(checksum == 0x4D25)

License

Licensed under the MIT License, refer to LICENSE.md for more information.

bitcrc_python's People

Contributors

devast8a avatar

Watchers

 avatar  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.