Download the PHP package exussum12/xxhash without Composer

On this page you can find all versions of the php package exussum12/xxhash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package xxhash

A pure PHP implementation of xxhash

Currently only working for the 32 bit version. (Pre PHP 7.4). 32 and 64 bit version both work with PHP 7.4

If speed is important use the FFI versions (PHP 7.4+)

XXHash is a fast hash designed for file integrity checking. Passwords should not be hashed with this, please use Argon2 or BCrypt.

On PHP 8.1 xxhash is included by default, please use that instead

hash('xxh32',  'string');

for string mode or

$context = hash_init('xxh3');
hash_update($context, 'String1'); // from fgets or similar
hash_update($context, 'String2'); // from fgets or similar
hash_final($context);

Installing

With composer

composer require exussum12/xxhash

Hashing input

xxhash has a seed, this is 0 by default. To make a new instance of xxhash run

use exussum12\xxhash\V32;
$seed = 0;
$hash = new V32($seed);

Then to hash input, run

$hash->hash('string'); ## to hash a string

or

$file = fopen('path/to/file.ext', 'r');
$hash->hashStream($file); # for a stream (better for large files)

The library can be called statically also, however this removes the ability to change the seed. The default see of 0 will be used

V32::hash('string'); ## to hash a string
$file = fopen('path/to/file.ext', 'r');
V32::hashStream($file); # for a stream (better for large files)

Static functions should in general be avoided, so the first method is the preferred method to use.

FFI

Since PHP 7.4 FFI allows PHP to call the native C client. This is much faster, and the preferred way if your running PHP 7.4

Speed Comparison

This is hashing a 320mb file using the stream method. The time is the time take (smaller is better)

Method Time Peak Memory
xxHash Binary 0.081 1604kb
FFI 0.194 27616kb
Pure PHP 49.218 27844kb

Memory measured using /usr/bin/time -v


All versions of xxhash with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-bcmath Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package exussum12/xxhash contains the following files

Loading the files please wait ....