PHP sha1_file() function

The sha1_file() function calculate the sha1 hash of a file

Syntax

sha1_file ( string $string ,raw_output=FALSE) : string

Parameters

Parameter Name Descrption
$string Required, The string.
raw_output Optional, Specifies the raw_output for hexadecimal number or binary format
  • TRUE - Raw 20 character binary format
  • FALSE(Default) - 40 character hexadecimal number

Return Value

When TRUE - Raw 20 bit character format, When FALSE- 40 character hexadecimal number

sha1_file() examples

$file = 'php_sha1_file.zip';
echo  sha1_file($file);

Related Functions

  • sha1(): Calculate the sha1 hash of a string
  • crc32(): Calculates the crc32 polynomial of a string
  • crypt(): One-way string hashing
  • md5(): Calculate the md5 hash of a string
  • md5_file(): Calculates the md5 hash of a given file