kittinan/php-crc

Calculates CRC checksums for input data

Maintainers

Details

github.com/kittinan/php-crc

Source

Installs: 48 877

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 8

1.0.0 2017-09-02 08:59 UTC

This package is auto-updated.

Last update: 2024-11-19 21:21:15 UTC


README

This is work in progress. I am not an expert on the topic by any means. Therefore, I have trouble finding and verifying information about common CRC algorithms. I am especially looking for reliable test vectors.

Implemented algorithms

  • CRC1
  • CRC16, CRC16-CCITT, CRC16-DNP, CRC16-Modbus, CRC16-QT, CRC16-USB, CRC16-XModem, CRC16-ZModem

Usage example

<?php

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

$crc16ccitt = new mermshaus\CRC\CRC16CCITT();

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

$checksum = $crc16ccitt->finish();

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

Testing

$ phpunit

Credits

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

Links