Monday, 29 September 2014

sha1_file in PHP

PHP sha1_file() function calculates the sha1 hash of file using the "The US Secure Hash Algorithm 1" and returns that hash.

Syntax:

sha1_file(file,raw)
file : Required. The file name to hash.

raw : Optional. Defines hex or binary output format: 
             TRUE – returns in  Raw binary format with length 20 character.
             FALSE – Default. 40 character hex number

Example:

<?php
$file_name = "test_file.txt";
$sha1_file_op = sha1_file($file_name);
echo $sha1_file_op;
?>
Output will be:
91433d300370a364481bef9fb5871b50f19c0417

0 comments:

Post a Comment