PHPackages                             google/crc32 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. google/crc32

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

google/crc32
============

Various CRC32 implementations

v0.2.0(3y ago)19254.4M—9.5%13[2 issues](https://github.com/google/php-crc32/issues)[2 PRs](https://github.com/google/php-crc32/pulls)6Apache-2.0PHPPHP &gt;=7.4

Since May 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/google/php-crc32)[ Packagist](https://packagist.org/packages/google/crc32)[ Docs](https://github.com/google/php-crc32)[ RSS](/packages/google-crc32/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (6)

php-crc32
=========

[](#php-crc32)

[![Build Status](https://github.com/google/php-crc32/actions/workflows/test.yml/badge.svg)](https://github.com/google/php-crc32/actions/workflows/test.yml/badge.svg)

by [Andrew Brampton](https://bramp.net)

**Deprecated**: Since PHP 8.0, the crc32 algorithms within PHP are using [hardware accelerated instructions](https://github.com/php/php-src/commit/c3299d7dab15aeed52a34535f1967d426f5327de), and are surprisingly fast. Thus this extension is not needed anymore!

CRC32 implementations, that support all crc32 polynomials, as well as (if you install the pecl extension) hardware accelerated versions of CRC32C (Castagnoli).

Supports PHP 7.4 though PHP 8.2. Older PHP versions are supported with "v0.1.0".

Usage
=====

[](#usage)

```
require 'vendor/autoload.php';

use Google\CRC32\CRC32;

$crc = CRC32::create(CRC32::CASTAGNOLI);
$crc->update('hello');
echo $crc->hash();
```

Depending on the environment and the polynomial, `CRC32::create` will choose the fastest available version, and return one of the following classes:

- `Google\CRC32\PHP` - A pure PHP implementation.
- `Google\CRC32\Builtin` - A [PHP Hash framework](http://php.net/manual/en/book.hash.php) implementation.
- `Google\CRC32\Google` - A hardware accelerated implementation (using [google/crc32c](https://github.com/google/crc32c)).

When reading 1M byte chunks, using `CRC32::CASTAGNOLI` with PHP 7.4 on a 2014 Macbook Pro we get the following performance (higher is better):

```
Google\CRC32\PHP           12.27 MB/s
Google\CRC32\Builtin       468.74 MB/s (available since PHP 7.4)
Google\CRC32\Google        24,684.46 MB/s (using crc32c.so)

```

Install
=======

[](#install)

```
$ composer require google/crc32
```

crc32c.so
=========

[](#crc32cso)

To use the hardware accelerated, a custom PHP extension must be installed. This makes use of [google/crc32c](https://github.com/google/crc32c) which provides a highly optomised `CRC32C` (Castagnoli) implementation using the SSE 4.2 instruction set of Intel CPUs.

The extension can be installed from pecl, or compiled from stratch.

```
TODO pecl install crc32c
```

Once installed or compiled, you'll need to add `extension=crc32c.so` to your php.ini file.

Compile (Linux / Mac)
---------------------

[](#compile-linux--mac)

Ensure that [composer](https://getcomposer.org), build tools (e.g [build-essential](https://packages.debian.org/sid/devel/build-essential), [cmake](https://packages.debian.org/sid/devel/cmake), etc), and php dev headers (e.g [php-dev](https://packages.debian.org/sid/php/php-dev)) are installed.

Simple (using Makefile):

```
make test
```

Alternatively (manually):

```
cd ext

# Install the google/crc32c library
./install_crc32c.sh # From source (recommended)

# or use your favorite package manager, e.g.
# brew install crc32c

# Prepare the build environment
phpize
./configure

# or if using a custom crc32c
# ./configure --with-crc32c=$(brew --prefix crc32c)

## Build and test
make test
```

The extension will now be at `ext/modules/crc32c.so`. This file should be copied to your [extension directory](https://php.net/extension-dir) and reference in your php.ini.

```
# php.ini
extension=crc32c.so

```

Testing
-------

[](#testing)

`make test` will test with the current PHP. `make test_all` will search for available PHP installs, and test with all of them.

Benchmark
---------

[](#benchmark)

To compare the performance of the different `CRC32C` implementations, run `make benchmark`.

Related
=======

[](#related)

-

TODO
====

[](#todo)

- Test if this works on 32 bit machine.
- Add php unit (or similar) testing.
- Publish to packagist
- Publish to pecl ()
- Update instructions for linux.

Licence (Apache 2)
==================

[](#licence-apache-2)

*This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.*

```
Copyright 2023 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity66

Solid adoption and visibility

Community24

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1438 days

Total

2

Last Release

1128d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4

v0.2.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3901206952845568d7557a60855b097f6d1bafaa7a24020cfcf5bb8de74f9d28?d=identicon)[google-cloud](/maintainers/google-cloud)

---

Top Contributors

[![bramp](https://avatars.githubusercontent.com/u/160627?v=4)](https://github.com/bramp "bramp (59 commits)")[![jdpedrie](https://avatars.githubusercontent.com/u/89034?v=4)](https://github.com/jdpedrie "jdpedrie (4 commits)")[![juan-morales](https://avatars.githubusercontent.com/u/25756860?v=4)](https://github.com/juan-morales "juan-morales (1 commits)")[![katrinleinweber](https://avatars.githubusercontent.com/u/9948149?v=4)](https://github.com/katrinleinweber "katrinleinweber (1 commits)")[![lvsantos1](https://avatars.githubusercontent.com/u/25807807?v=4)](https://github.com/lvsantos1 "lvsantos1 (1 commits)")[![shyim](https://avatars.githubusercontent.com/u/6224096?v=4)](https://github.com/shyim "shyim (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/google-crc32/health.svg)

```
[![Health](https://phpackages.com/badges/google-crc32/health.svg)](https://phpackages.com/packages/google-crc32)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
