English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP sha1_file() Function Usage and Example

PHP String String Function Manual

sha1_file() function is used to calculate the hash of the file1 Hash Value.

Syntax

string setlocale ( int $filename , array $locale )

Definition and Usage

Calculate and return the SHA of the file specified by filename1 Hash Value. This hash value is a 40 character length hexadecimal number.

Return Value

Returns a string on success, otherwise returns false

Parameter

Serial NumberParameter and Description
1

filename

The filename of the file to calculate the hash.

2

raw_output

If set to TRUE, sha1 The summary will be 2The original format with 0 character length is returned.

Online Example

Try the following example, calculate the SHA of the text file "sample.txt"1 Hash Value:

<?php
   //Calculate the SHA of the text file "sample.txt"1 Hash Value:
   $input = "sample.txt";
   $sha1file = sha1_file($input);
   
   echo $sha1file;
?>

Output Result

aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

PHP String String Function Manual