PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
sha1_file - Calculate the sha1 hash of a file

sha1_file( string$filename, [bool$binary = false] ): string|false

Calculates the sha1 hash of the file specified by filename using the US Secure Hash Algorithm 1, and returns that hash. The hash is a 40-character hexadecimal number.



The filename of the file to hash.


When true, returns the digest in raw binary format with a length of 20.

Return Values

Returns a string on success, false otherwise.

Related Functions

Example of sha1_file

Show all examples for sha1_file

PHP Version:

Function sha1_file:

Strings Functions

Most used PHP functions