Generate BLAKE2b Hash using PHP

Sodium extension

  1. Enable extension in php.ini file:
extension=sodium
  1. Generate BLAKE2b hash:
<?php

$digestSize = 64; // 64 (512-bit), 48 (384-bit), 32 (256-bit), 28 (224-bit)

$text = 'Hello';
$digest = bin2hex(sodium_crypto_generichash($text, length: $digestSize));

echo $digest;

Leave a Comment

Cancel reply

Your email address will not be published.