欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP sha1_file() 函數(shù)

定義和用法

sha1_file() 函數(shù)計(jì)算文件的 SHA-1 散列。

sha1() 函數(shù)使用美國(guó) Secure Hash 算法 1。

如果成功,則返回所計(jì)算的 SHA-1 散列,如果失敗,則返回 false。

語(yǔ)法

sha1_file(string,raw)
參數(shù) 描述
string 必需。規(guī)定要計(jì)算的文件。
raw

可選。規(guī)定十六進(jìn)制或二進(jìn)制輸出格式:

  • TRUE - 原始 20 字符二進(jìn)制格式
  • FALSE - 默認(rèn)。40 字符十六進(jìn)制數(shù)

注釋?zhuān)涸搮?shù)是 PHP 5.0 中添加的。

例子

例子 1

<?php
$filename = "test.txt";
$sha1file = sha1_file($filename);
echo $sha1file;
?>

輸出:

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

例子 2

在一個(gè)文件中存儲(chǔ) "test.txt" 的 SHA-1 散列:

<?php
$sha1file = sha1_file("test.txt");
file_put_contents("sha1file.txt",$sha1file);
?>

在本例中,我們將測(cè)試 "test.txt" 是否已更改(即 SHA-1 hash 是否已更改):

<?php
$sha1file = file_get_contents("sha1file.txt");
if (sha1_file("test.txt") == $sha1file)
  {
  echo "The file is ok.";
  }
else
  {
  echo "The file has been changed.";
  }
?>

輸出:

The file is ok.