sha1_file – PHP String Functions
Syntax :
Description :
sha1_file() function 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.
Parameter :
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|lef|lef|left”]
Name, Required /Optional, Value Type, Description
filename , Required, String , The file for which hash is to be calculated.
raw_output, Optional, boolen, A boolean value that specifies hex or binary output format:
,,If TRUE, Raw 20 character binary format data will be returned.
,,If FALSE, Default 40 character hex number will be returned.
[/table]
Output :
This function returns the string, calculated for SHA-1 hash of a file on success, or FALSE on failure.
ChangeLog :
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, Description
PHP 5.1.0 , Changed the function to use the streams API. It means that you can use it with wrappers like sha1_file(‘http://www.tutorialmines.net/..’)
[/table]
Related articles : md5(), sha1(), crc32(), md5_file().
sha1_file() – PHP Functions Example 1 :
<?php $filename = "example1.txt"; $sha1file = sha1_file($filename); echo $sha1file; ?>