查詢

sodium_crypto_core_ristretto255_from_hash()函式—用法及示例

「 將一個雜湊值轉換為Ristretto 255點 」


函式名:sodium_crypto_core_ristretto255_from_hash()

適用版本:PHP 7.2.0及以上版本

函式說明:sodium_crypto_core_ristretto255_from_hash()函式將一個雜湊值轉換為Ristretto 255點。

用法:

sodium_crypto_core_ristretto255_from_hash(string $hash): string

引數:

  • $hash:一個32位元組的二進位制字串,表示要轉換為Ristretto 255點的雜湊值。

返回值:

  • 返回一個32位元組的二進位制字串,表示Ristretto 255點。

示例:

$hash = random_bytes(SODIUM_CRYPTO_GENERICHASH_BYTES);
$point = sodium_crypto_core_ristretto255_from_hash($hash);
echo bin2hex($point);

在上面的示例中,我們首先生成一個隨機的32位元組雜湊值,然後使用sodium_crypto_core_ristretto255_from_hash()函式將雜湊值轉換為Ristretto 255點。最後,我們將轉換後的點列印出來,使用bin2hex()函式將二進位制字串轉換為十六進位制表示。

補充糾錯
熱門PHP函式
分享連結