Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mermshaus/CRC

I’m not an expert on the topic by any means. Therefore, I have trouble finding and verifying information about common CRC algorithms.

Implemented algorithms

Alias names in parentheses.

  • CRC-1 [1]
  • CRC-16 [2]
  • CRC-16/IBM-3740 (CRC-16/CCITT-FALSE)
  • CRC-16/DNP
  • CRC-16/MODBUS
  • CRC-16/IBM-SDLC (CRC16-QT [3])
  • CRC-16/USB
  • CRC-16/XMODEM (CRC-16/ZMODEM)

1: Might be a misnomer inherited from the algorithm list this library was built against.

2: Most likely CRC-16/ARC.

3: This was also part of the original library. It doesn’t seem to be a catalogue alias. That’s why it’s not formatted as one.

Usage example

<?php

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

$crc = new \mermshaus\CRC\CRC16IBM3740();

$crc->update('Hello');
$crc->update(' World!');

$checksum = $crc->finish();

var_dump(bin2hex($checksum)); // string(4) "882a"

Testing

Note: The current test setup tries to use the PHP version installed on the system (php command). If none is found, it will try to build a Docker container based on php-cli and use that.

$ make test

Credits

  • This library is mostly a port of Digest CRC for Ruby by Hal Brodigan.

Links

About

Calculates CRC checksums for input data.

Resources

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages