PHP wrapper for the BLAKE2 hashing function
C PHP M4
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
.travis.yml
LICENSE
README.md
blake2-impl.h
blake2.h
blake2b-ref.c
config.m4
php_blake2.c
php_blake2.h Initial commit Dec 23, 2012

README.md

PHP BLAKE2 Extension

Build Status

BLAKE2 is an improved version of BLAKE, one the finalists in the NIST SHA-3 competition. Like BLAKE or SHA-3, BLAKE2 offers the highest security, yet is fast as MD5 on 64-bit platforms and requires at least 33% less RAM than SHA-2 or SHA-3 on low-end systems. This implementation uses the BLAKE2b variant of the algorithm which is optimized for 64-bit systems. The algorithm was designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn, and Christian Winnerlein.

Installation

  1. git clone https://github.com/strawbrary/php-blake2
  2. cd php-blake2
  3. phpize
  4. ./configure --enable-blake2
  5. make && make install
  6. Add the following line to your php.ini file
extension=blake2.so

You may need to restart your httpd to load the extension

Usage

string blake2 ( string $str [, int $outputSize = 64, string $key, bool $rawOutput = false ] )
  • $str: The string to hash
  • $outputSize: The length of the output hash (can be between 1 and 64)
  • $key: Turns the output into a keyed hash using the specified key
  • $rawOutput: If set to true, then the hash is returned in raw binary format

  • Return value: A hex string containing the BLAKE2 hash of the input string

Examples

echo blake2('');

786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce

echo blake2('Hello world', 20);

5ad31b81fc4dde5554e36af1e884d83ff5b24eb0

echo blake2('Hello world', 20, 'foobar');

5b4bbc84b59ab5d9146089b143fd52f38638dcac

More Info

https://blake2.net/