Search by

Calculates CRC checksums for input data.

Package info

github.com/mermshaus/php-crc

pkg:composer/mermshaus/crc

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 13

Open Issues: 0

v1.0.0 2026-08-25 07:44 UTC

This package is auto-updated.

Last update: 2026-08-25 10:34:21 UTC


README

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