Download the PHP package regexp1987/blake3 without Composer

On this page you can find all versions of the php package regexp1987/blake3. 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 blake3

PHP BLAKE3 Extension

Native PHP extension for the BLAKE3 cryptographic hash function, based on the official C reference implementation from the BLAKE3 team.

Why BLAKE3?

Feature BLAKE3 SHA-256 MD5
Speed (x86_64) ~1.3 GB/s ~0.3 GB/s ~0.5 GB/s
Output length Arbitrary (XOF) Fixed 32 bytes Fixed 16 bytes
Security ✅ 256-bit ✅ 256-bit ❌ Broken
Keyed mode (MAC) ✅ ❌ (needs HMAC) ❌
Incremental ✅ ✅ ✅

BLAKE3 is 4× faster than SHA-256 on modern CPUs thanks to SIMD parallelism (AVX-512, AVX2, SSE4.1, SSE2, NEON). It's ideal for:

Requirements

Component Minimum Recommended
PHP 8.1 8.4+
GCC 9+ 12+
Clang 10+ 15+
OS Linux / macOS / BSD Linux x86_64
Windows Visual Studio 2019+ Visual Studio 2022+

Installation

Via PIE (Recommended — PHP Installation & Extensions)

PIE is the modern PHP extension installer (replaces deprecated PECL). Requires PHP 8.1+.

PIE automatically:

From source (Linux / macOS / BSD)

If you prefer manual installation or don't have PIE:

Windows (Visual Studio)

Copy Release\php_blake3.dll to your PHP ext directory and add extension=php_blake3.dll to php.ini.

Docker

API Reference

Functions

blake3(string $data, int $output_length = 32, ?string $key = null, bool $raw_output = false): string

One-shot BLAKE3 hash. Returns lowercase hex by default.

Parameters: Parameter Type Default Description
$data string required Input data to hash
$output_length int 32 Output length in bytes (1–2^64−1, limited by available memory)
$key string|null null 32-byte key for keyed-hash (MAC) mode
$raw_output bool false If true, return raw bytes instead of hex

Returns: string — lowercase hex digest, or raw bytes if $raw_output = true

Throws: ValueError if $key is not exactly 32 bytes, or $output_length < 1


blake3_file(string $filename, int $output_length = 32, ?string $key = null, bool $raw_output = false): string

Hash a file using streaming (8 KB chunks). Memory-efficient for large files.

Parameters: Parameter Type Default Description
$filename string required Path to the file
$output_length int 32 Output length in bytes
$key string|null null 32-byte key for keyed-hash (MAC) mode
$raw_output bool false If true, return raw bytes

Returns: string — hex digest or raw bytes; false on read error

Throws: ValueError if $filename is empty, $output_length < 1, or $key is not exactly 32 bytes


blake3_hash(string $data, int $output_length = 32): string

Convenience alias for blake3($data, $output_length, null, false). Returns hex string. Kept for backward compatibility.


blake3_hash_raw(string $data, int $output_length = 32): string

Convenience alias for blake3($data, $output_length, null, true). Returns raw binary string.


blake3_keyed_hash(string $data, string $key, int $output_length = 32): string

Convenience alias for blake3($data, $output_length, $key, false). Keyed-hash (MAC) mode. $key must be exactly 32 bytes.


blake3_init(?string $key = null): Blake3Context

Initialise an incremental hashing context.

With key:

Parameters: Parameter Type Default Description
$key string|null null 32-byte key for keyed-hash mode

Returns: Blake3Context — opaque handle for incremental hashing

Throws: ValueError if $key is provided but not exactly 32 bytes


blake3_update(Blake3Context $ctx, string $data): void

Append data to an incremental hash context.

Throws: ValueError if $ctx is not a valid Blake3Context


blake3_final(Blake3Context $ctx, bool $raw_output = false): string

Finalise the incremental hash and return the digest.

Parameters: Parameter Type Default Description
$ctx Blake3Context required The hashing context (consumed — cannot reuse)
$raw_output bool false If true, return raw bytes

Returns: string — hex digest or raw bytes

Note: After calling blake3_final(), the context is consumed. Use blake3_reset() to reinitialise it, or create a new context with blake3_init() for subsequent hashes.


blake3_xof(string $data, int $output_length, ?string $key = null, bool $raw_output = false): string

Extendable Output Function (XOF). Equivalent to blake3() with an explicit, required output length.

Parameters: Parameter Type Default Description
$data string required Input data
$output_length int required Output length in bytes (must be ≥ 1)
$key string|null null 32-byte key for keyed-hash (MAC) mode
$raw_output bool false If true, return raw bytes


blake3_derive_key(string $context, string $key_material, int $output_length = 32, bool $raw_output = false): string

Key Derivation Function (KDF) mode. Derives a key from a context string and key material. The context string must be unique to the application and protocol version — it is not secret.

Parameters: Parameter Type Default Description
$context string required Non-empty application context string (e.g. "my-app v1 purpose")
$key_material string required Non-empty secret key material
$output_length int 32 Output length in bytes
$raw_output bool false If true, return raw bytes

Returns: string — hex digest or raw bytes

Throws: ValueError if $context or $key_material is empty, or $output_length < 1


blake3_version(): string

Returns the BLAKE3 library version string.

Class: Blake3Context

Opaque resource handle returned by blake3_init(). Cannot be instantiated directly.

Constants

Constant Value Description
BLAKE3_OUT_LEN 32 Default output length (bytes)
BLAKE3_KEY_LEN 32 Key length for MAC mode (bytes)
BLAKE3_BLOCK_LEN 64 Block size (bytes)
BLAKE3_MAX_DEPTH 54 Maximum tree depth
BLAKE3_MAX_OUTPUT 67108864 Maximum output length enforced by this extension (64 MB)

Benchmark

Compare BLAKE3 with PHP built-in hash functions:

Typical results (Intel Core i7, Linux x86_64):

Test Vectors

Known Limitations

License

MIT License — see LICENSE.

The bundled BLAKE3 C reference implementation is dual-licensed under CC0 and the Apache License 2.0.

Credits


All versions of blake3 with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
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 regexp1987/blake3 contains the following files

Loading the files please wait ...