W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)
hash_file — 給指定文件的內(nèi)容生成散列值
hash_file(
string $algo,
string $filename,
bool $binary = false,
array $options = []
): string|false
algo
要使用的散列算法的名稱(chēng)(例如:“md5”、“sha256”、“haval160,4”等)。 可以在 hash_algos() 中查看當(dāng)前支持的算法。
filename
要進(jìn)行散列運(yùn)算的文件位置的 URL;支持 fopen 封裝協(xié)議。
binary
設(shè)置為 true
時(shí),輸出原始二進(jìn)制數(shù)據(jù)。 設(shè)置為 false
時(shí),輸出小寫(xiě)的十六進(jìn)制字符串。
options
各種散列算法的一系列選項(xiàng)數(shù)組。目前 MurmurHash 算法僅支持 “seed” 參數(shù)。
如果 binary 設(shè)置為 true, 則返回原始二進(jìn)制數(shù)據(jù)表示的信息摘要, 否則返回十六進(jìn)制小寫(xiě)字符串格式表示的信息摘要。
版本 | 說(shuō)明 |
---|---|
8.1.0 | 新增 options 參數(shù)。 |
示例 #1 hash_file() 示例
<?php
/* Create a file to calculate hash of */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
echo hash_file('sha256', 'example.txt');
?>
以上示例會(huì)輸出:
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: