PHP sha1_file() Function
PHP sha1_file() Function
The sha1_file() in PHP calculates the sha1 hash of a file and returns the hash (40-character hexadecimal number).
Syntax
sha1_file ( string $filename [, bool $raw_output] )
Parameter
filename(required)- This parameter represents the filename of the file to hash.
raw_output(optional)- This parameter takes a Boolean value and returns the digest in raw binary format with a length of 20 if Boolean TRUE is passed.
Return
This function returns a string on success, FALSE otherwise.
Example 1
text.txt
Hello World
Test.php
$filename = "test.txt";
$sha1file = sha1_file($filename);
echo $sha1file;
?>
Output
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
