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

PHP sha1_file() 函數(shù)

定義和用法

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

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

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

語法

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

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

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

注釋:該參數(shù)是 PHP 5.0 中添加的。

例子

例子 1

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

輸出:

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

例子 2

在一個文件中存儲 "test.txt" 的 SHA-1 散列:

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

在本例中,我們將測試 "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.