PHPackages                             cypherbits/php-blake3 - 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. [Security](/categories/security)
4. /
5. cypherbits/php-blake3

ActivePhp-ext[Security](/categories/security)

cypherbits/php-blake3
=====================

BLAKE3 hashing algorithm PHP extension (native C, SIMD) for fast cryptographic hashing.

v202511241(5mo ago)18431[1 issues](https://github.com/cypherbits/php-blake3/issues)MITAssemblyPHP &gt;=8.3

Since Nov 24Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/cypherbits/php-blake3)[ Packagist](https://packagist.org/packages/cypherbits/php-blake3)[ Docs](https://github.com/cypherbits/php-blake3)[ Fund](https://ko-fi.com/cypherbits)[ RSS](/packages/cypherbits-php-blake3/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (2)Used By (0)

PHP BLAKE3 Extension
====================

[](#php-blake3-extension)

BLAKE3 is an improved and faster version of BLAKE2.

This extension uses the official BLAKE3 C implementation, thus is single-threaded, but still faster than SHA256 or SHA512 on benchmark (PHP 7.4).

Installation (manual)
---------------------

[](#installation-manual)

Clone the repository and compile it:

```
$ git clone https://github.com/cypherbits/php-blake3.git
$ cd php-blake3
$ phpize
$ ./configure --enable-blake3
$ make && sudo make install
```

Enable the extension by adding the following line to your php.ini file:

```
extension=blake3.so
```

You may need to restart your web server to load the extension.

Usage
-----

[](#usage)

**Global constants:**

`BLAKE3_OUT_LEN: 32`

**Functions:**

```
string blake3 ( string $str [, int $outputSize = 32, string $key, bool $rawOutput = false ] )
```

- $str: The string to hash
- $outputSize: The length of the output hash in bytes (must be &gt;= 1). BLAKE3 supports extendable output so larger values are allowed; the default is 32 bytes.
- $key: Turns the output into a keyed hash using the specified key. It MUST be of 32 bytes long.
- $rawOutput: If set to true, then the hash is returned in raw binary format
- Return value: A hex string containing the BLAKE3 hash of the input string. Default output size: 32 bytes.

```
string blake3_file ( string $filename [, bool $rawOutput = false ] )
```

- $filename: The filename of the file to hash
- $rawOutput: If set to true, then the hash is returned in raw binary format
- Return value: A hex string containing the BLAKE3 hash of the input file

Examples
--------

[](#examples)

```
echo blake3('');
```

af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262

```
echo blake3('Hello world', 20);
```

e7e6fb7d2869d109b62cdb1227208d4016cdaa0a

```
echo blake3('Hello world', 32, 'cae8954e7b3415ea18303db548e15207');
```

75672fafd13480d2325914f0665795eceecad4e668d9ea2a87c40e71232a7d3a

Benchmarks
----------

[](#benchmarks)

```
