google/crc32
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The google/crc32 PHP package by Google incorporates various implementation of CRC32, supporting all CRC32 polynomials. This package also offers hardware-accelerated versions of CRC32C (Castagnoli) when paired with additional PECL extension. Similar to other CRC (Cyclic Redundancy Check) implementations, this package computes checksums of data to detect possible errors during transmission or storage. However, since PHP 8.0, these internal crc32 algorithms are deprecating the need for this extension, due to PHP's accelerated hardware support.
The google/crc32 library can be quickly and effortlessly implemented in your PHP project with Composer package manager. You should first install the package using Composer by running the command composer require google/crc32
. Once installed, you can use CRC32 in your PHP scripts as follows:
require 'vendor/autoload.php';
use Google\CRC32\CRC32;
$crc = CRC32::create(CRC32::CASTAGNOLI);
$crc->update('hello');
echo $crc->hash();
This script demonstrates the creation of a new CRC32 object with the Castagnoli polynomial and updates it with sample text 'hello', subsequently displaying the ensuing hash result.
Remember that CRC32 also has hardware-accelerated versions available through the use of a custom CRC32C PHP extension. To activate it, you must install the extension by following the setup instructions embedded within the readme file, ending with adding extension=crc32c.so
to your php.ini file.
Documentation for google/crc32 is principally contained within the package's README file available on the Github repository. The README provides a basic overview of the google/crc32 package, detailing its functionalities and instructions for installation and usage. More complex or targeted queries should be directed towards googling API docs or the comparable PHP CRC32 functionalities.