A PHP extension to add support for the xxHash fast hashing algorithm.
xxHash is an Extremely fast Hash algorithm, running at RAM speed limits. It successfully completes the SMHasher test suite which evaluates collision, dispersion and randomness qualities of hash functions.
Please note at the moment the master branch should be used for PHP 5.x and develop branch should be used for PHP 7.x
phpize
./configure --enable-xxhash
make
sudo make install
Don't forget to load the extension in via php.ini or the like.
More details can be found here: https://www.sitepoint.com/install-php-extensions-source/
To use with docker compose
RUN curl -fsSL 'https://github.com/tawkirahmed/php-xxhash/archive/develop.zip' -o xxhash.zip \
&& mkdir -p xxhash \
&& unzip -j xxhash.zip -d xxhash\
&& rm xxhash.zip \
&& ( \
cd xxhash \
&& phpize \
&& ./configure --enable-xxhash \
&& make -j "$(nproc)" \
&& make install \
) \
&& rm -r xxhash \
&& docker-php-ext-enable xxhash
Upon installation and enabling the extension within php.ini the following two new functions will be available to you:
long xxhash32(string $data);
long xxhash64(string $data);
In both cases a long number will be returned, representing the digest (hash) of the $data input.
Beware that in case of xxhash64
negative number can be returned since php does not support unsigned long.
- Original implementation of php-xxhash by Stuart Herbert.
- xxHash by Yann Collet.
BSD 2-clause license.