= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)hash_final — 結(jié)束增量哈希,并且返回摘要結(jié)果說(shuō)明hash_final(HashContext $context, bool $raw_output = false): st">

hash_final

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)

hash_final結(jié)束增量哈希,并且返回摘要結(jié)果

說(shuō)明

hash_final(HashContext $context, bool $raw_output = false): string

參數(shù)

context

hash_init() 函數(shù)返回的哈希運(yùn)算上下文資源。

raw_output

設(shè)置為 true,輸出格式為原始的二進(jìn)制數(shù)據(jù)。 設(shè)置為 false,輸出小寫(xiě)的 16 進(jìn)制字符串。

返回值

如果 raw_output 設(shè)置為 true, 則返回原始二進(jìn)制數(shù)據(jù)表示的信息摘要, 否則返回 16 進(jìn)制小寫(xiě)字符串格式表示的信息摘要。

更新日志

版本 說(shuō)明
7.2.0 接收參數(shù)從資源類(lèi)型修改為 HashContext 對(duì)象類(lèi)型。

范例

示例 #1 hash_final() 例程

<?php
$ctx 
hash_init('sha1');
hash_update($ctx'The quick brown fox jumped over the lazy dog.');
echo 
hash_final($ctx);
?>

以上例程會(huì)輸出:

c0854fb9fb03c41cce3802cb0d220529e6eef94e

參見(jiàn)

  • hash_init() - 初始化增量哈希運(yùn)算上下文
  • hash_update() - 向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)
  • hash_update_stream() - 從打開(kāi)的流向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)
  • hash_update_file() - 從文件向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)