PHP - hash_update() 函式



定義和用法

hash_update() 函式將使用雜湊上下文更新給定的資料。

語法

hash_update(HashContext $context , string $data ): bool

引數

序號 引數及描述
1

HashContext context

使用 hash_init() 獲取的雜湊上下文。

2

data

要與雜湊上下文混合的資料。

返回值

PHP hash_update() 函式返回布林值,即 true/false。

PHP 版本

此函式適用於 PHP 5.1.2 以上版本。

示例 1

使用 hash_update -

<?php
   $hash_context = hash_init('md5');
   hash_update($hash_context, 'Testing php');
   hash_update($hash_context, ' hash functions.');
   echo hash_final($hash_context);
?>

輸出

這將產生以下結果 -

e4310012c89a4b8479fd83694a2a3a31

示例 2

使用 gost-crypto 演算法的 hash_update -

<?php
   $hash_context = hash_init('gost-crypto');
   hash_update($hash_context, 'Hello World');
   echo hash_final($hash_context);
?>

輸出

這將產生以下結果 -

75ed15d84df84291c67fe07bf234ac69e92a9c2a378ee62f342af739e829eba9
php_function_reference.htm
廣告