Coder Social home page Coder Social logo

crc's Introduction

CRC Build Status Scrutinizer Code Quality

This is an implementation of the CRC RevEng Catalogue in PHP 7.x

How to use

<?php

// Autoloading via Composer
require __DIR__ . '/vendor/autoload.php';

$crc8 = new \PBurggraf\CRC\CRC8\CRC8();
var_dump(dechex($crc8->calculate('123456789'))); // string(2) "f4"

$crc16AugCcitt = new \PBurggraf\CRC\CRC16\AugCcitt();
var_dump(dechex($crc16AugCcitt->calculate('123456789'))); // string(4) "e5cc"

$crc24 = new \PBurggraf\CRC\CRC24\CRC24();
var_dump(dechex($crc24->calculate('123456789'))); // string(6) "21cf02"

$crc32 = new \PBurggraf\CRC\CRC32\CRC32();
var_dump(dechex($crc32->calculate('123456789'))); // string(8) "cbf43926"

Test

This project uses phpunit to test the validation of crc calculations.

Currently implemented

8bit CRC

AUTOSAR, BLUETOOTH, CDMA2000, DARC, DVB-S2, GSM-A, GSM-B, I-432-1 (ITU), I-CODE, LTE, MAXIM-DOW (MAXIM, DOW-CRC), MIFARE-MAD, NRSC-5, OPENSAFETY, ROHC, SAE-J1850, SMBUS (CRC-8), TECH-3250 (AES, EBU)

16bit CRC

ARC (CRC-16, LHA, CRC-IBM), CDMA2000, CMS, DDS-110, DECT-R (R-CRC-16), DECT-X (X-CRC-16), DNP, EN-13757, GENIBUS (DARC, EPC, EPC-C1G2, I-CODE), GSM, IBM-3740 (AUTOSAR, CCITT-FALSE), IBM-SDLC (ISO-HDLC, ISO-IEC-14443-3-B, X-25, CRC-B), ISO-IEC-14443-3-A (CRC-A), KERMIT (CCITT, CCITT-TRUE, V-41-LSB, KERMIT), LJ1200, MAXIM-DOW (MAXIM), MCRF4XX, MODBUS, NRSC-5, OPENSAFETY-A OPENSAFETY-B, PROFIBUS (IEC-61158-2), RIELLO, SPI-FUJITSU (AUG-CCITT), T10-DIF, TELEDISK, TMS37157, UMTS (BUYPASS, VERIFONE), USB, XMODEM (ACORN, LTE, V-41-MSB, ZMODEM)

24bit CRC

BLE, FLEXRAY-A, FLEXRAY-B, INTERLAKEN, LTE-A, LTE-B, OPENPGP (CRC-24)

32bit CRC

AIXM (CRC-32Q), AUTOSAR, BASE91-D (CRC-32D), BZIP2 (AAL5, DECT-B, B-CRC-32), CD-ROM-EDC, CKSUM (POSIX), ISCSI (BASE91-C, CASTAGNOLI, INTERLAKEN, CRC-32C), ISO-HDLC (CRC-32, ADCCP, V-42, XZ, PKZIP), JAMCRC, MPEG-2, XFER

crc's People

Contributors

pburggraf avatar peter279k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

crc's Issues

Package gets identified as phpstan-extension

I am using phpstan/extension-installer to autoload all phpstan extensions. It tries to find a phpstan extension file in this package:

./vendor/bin/phpstan analyse
Note: Using configuration file /path/to/project/phpstan.neon.
Config file /path/to/project/vendor/pburggraf/crc/extension.neon does not exist or isn't readable

According to https://github.com/phpstan/extension-installer#instructions-for-extension-developers I think, you should remove the following part from your composer.json:

 "extra": {
    "phpstan": {
      "includes": [
        "extension.neon"
      ]
    }
  }

Multiple performance issues in the library

There is some serious performance issues in the library

  1. The lookup table is generated in the constructor, this slows down the instantiation of a class, the constructor should not have heavy logic and it would be much better to use dependency injection and pass the lookup table as an argument.
  2. The lookup table is never used (!), there is a table generation for literally nothing as we don't rely on the lookup table at all to generate CRCs

Those issues make the library way slower than it should be, for nothing. Either the lookup table should be removed from the constructor, either it should be used later on (but I dislike the idea of generating a table to then use it, it doesn't make sense) or better: we can inject the lookup table to speed up calculation, if not it will rely on the current implementation.

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.