Blake3 PHP Extension

While PHP’s built-in hashing functions like sha256() are reliable, they can’t match the raw speed of modern algorithms running in compiled code. For applications that require hashing large volumes of data—such as verifying multi-gigabyte files or powering data-intensive APIs—every millisecond counts. Offloading this work from the PHP engine to native code is the key to unlocking maximum performance.

What is the BLAKE3 PHP Extension?

The Codernix BLAKE3 PHP Extension is a native extension that seamlessly integrates the BLAKE3 hashing algorithm into the PHP language. It acts as a direct, high-speed bridge to our BLAKE3 C Wrapper, making the world’s fastest cryptographic hash function available as a simple PHP function: blake3_hash().

By calling this function, your PHP application bypasses the overhead of the Zend Engine and executes the hashing logic in highly-optimized, compiled Rust code, delivering unparalleled performance.

View Project on GitHub →

Why It Matters for PHP Developers

This extension provides a no-compromise solution for developers who need both the development speed of PHP and the execution speed of a low-level language for cryptographic tasks.

  • Extreme Performance: By executing outside the PHP interpreter, blake3_hash() is dramatically faster than calling hash('sha256', $data) or other native PHP functions, especially for large inputs.
  • Simple & Native API: Installation is straightforward, and usage is effortless. Once enabled, blake3_hash() works just like any other built-in PHP function, requiring no special libraries or complicated setup in your code.
  • Modern Security: Leverage a state-of-the-art cryptographic hash function designed by leading experts, ensuring your application benefits from the latest advancements in security and speed.

Use Case: High-Speed Data Integrity

Imagine you are developing a cloud storage platform where users upload and download large video files. To prevent data corruption, you must verify the integrity of each file.

Using PHP’s native hash_file('sha256', $path) could take several seconds for a multi-gigabyte file, locking up a PHP-FPM worker and reducing your server’s capacity. By using blake3_hash(file_get_contents($path)), the entire operation is executed as a single, highly-optimized native call, completing the task in a fraction of the time. This allows your application to handle more concurrent users and provides a much snappier experience.

Getting Started

To use the extension, the Codernix BLAKE3 C Wrapper must first be installed on your system. After that, the extension can be compiled and enabled using the standard phpize, configure, and make workflow.

For complete, step-by-step instructions, please see the project’s README file on GitHub.