PHP sha1_file Function

What is sha1_file Function?

Explanation

In PHP this function is used to calculate the sha1 hash of a file, using the US Secure Hash Algorithm.Its another like the md5 Algorithm.

Syntax:


sha1_file(file,raw)

In the above syntax "file" specifies the file to calculate sha1 hash, "raw" specifies the output format by default its hexadecimal, if the value is true then the output will be in binary format.

Example :


<?php
$file = "test.txt";
$eg = sha1_file($file);
echo $eg;
?>
Result :

fd38d62ecce120361fd81d1b33d4664da461c265

In the above sha1_file function example a text file "test.txt" which has the text "HIOX INDIA" is encrypted in sha1file algorithm.

PHP Topics


Ask Questions

Ask Question