Aucune description

Nichlas Severinsen f284892e53 Updated CHANGELOG.md il y a 4 ans
include f64831ea7d Finalizing XXH3 implementation il y a 4 ans
src f64831ea7d Finalizing XXH3 implementation il y a 4 ans
tests f64831ea7d Finalizing XXH3 implementation il y a 4 ans
.editorconfig df8af49600 Initial commit il y a 4 ans
.gitignore 647e12d214 Added .gitignore and CHANGELOG.md il y a 4 ans
.php_cs 24d42baa4e Structure changes il y a 4 ans
CHANGELOG.md f284892e53 Updated CHANGELOG.md il y a 4 ans
COPYING f64831ea7d Finalizing XXH3 implementation il y a 4 ans
LICENSE.txt df8af49600 Initial commit il y a 4 ans
README.md f64831ea7d Finalizing XXH3 implementation il y a 4 ans
composer.json 347941cae2 More tests, more implementation il y a 4 ans
phpunit.xml 24d42baa4e Structure changes il y a 4 ans

README.md

Necklace\XxHash - PHP FFI bindings for libxxhash

This is an FFI binding of the libxxHash library from xxHash for PHP.

You're here because:

  • You want xxHash in PHP.
  • You don't want to install an extension.
  • You're fine with installing the xxhash package on your system to get libxxHash.
  • You want speed, or at least more speed than a pure PHP implementation of xxHash could get.

If so, you're in the right place.

Getting started

Setup

You will obviously need the xxHash package. In addition you will need libffi, and enable FFI for PHP (You will therefore need PHP version 7.4 or above).

Here are some common ways to install:

  • Arch GNU/Linux: sudo pacman -S xxhash libffi
  • Debian / Ubundu: sudo apt install xxhash libffi
  • Fedora: sudo dnf install xxhash libffi
  • OpenSUSE: sudo zypper install xxhash libffi

PHP has to be compiled with the --with-ffi option, most distributions will have done this.

Locate the relevant php.ini file on your system and make sure this line is there, uncommented:

extension=ffi

Let me hash already!

Alright, alright. I know what you want, and I got what you need. You've got files, we got hashes:

Hash a file

<?php

use Necklace\XxHash\XxHash64;

$xxh = XxHash64;

echo $xxh->hashFile('filename');

2e790d069a07b05183ff80eedd51d542

Look in tests/ for more examples.

License

This repository and all its files is under the same license as the xxHash project; the BSD 2-Clause License.

See COPYING or LICENSE.txt.

Development

Clone and run composer install.

Tests

Run all tests with php vendor/bin/phpunit from the top directory.