PHP sha1 file

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : sha1_file() function

Last update on September 09 2017 06:08:52 (UTC/GMT +8 hours)

Description

The sha1_file() function is used to calculate the sha1 hash (Using US Secure Hash Algorithm 1 ) of a file.

Version

(PHP 4 and above)

Syntax

sha1_file (file_name, raw_output)

Parameter

Name Description Required /
Optional
Type
file_name The input file name. Required String
raw_output If TRUE sets raw 20 characters binary format. If FALSE (default) sets raw 40 character hex number format. Optional Boolean

Return value

Returns a string on success, FALSE otherwise.

Value Type : String.

Pictorial Presentation

php-string-sha1_file()

Example :

  1. <?php  
  2. $file_handler = 'testvf.txt';  
  3. $sha1_file = sha1_file($file_handler);  
  4. echo $sha1_file;  
  5. ?>   

Output :

833cd96367d51bb065f486f4b2bd7fe8bcb70996