PHP code example of st-all-one / blake3

1. Go to this page and download the library: Download st-all-one/blake3 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

st-all-one / blake3 example snippets




declare(strict_types=1);

ake3_hash;

echo blake3_hash('hello'), PHP_EOL;            // 64 lowercase hex chars
echo blake3_hash('hello', 64), PHP_EOL;        // XOF: 128 hex chars
echo bin2hex(blake3_hash('hello', 32, true));  // raw 32-byte output

use StAllOne\Blake3\Hasher;

$hasher = Hasher::new();
$hasher->update('first chunk');
$hasher->update('second chunk');
echo $hasher->finalize();       // hex
echo $hasher->finalize(64);     // XOF, hex
echo $hasher->finalize(32, true); // raw bytes

$hasher = Hasher::newKeyed(str_repeat("\x42", 32));
$hasher = Hasher::newDeriveKey('my-app/v1/session-key');