PHP sha1_file() Function

PHP sha1_file() Function is used to generate the SHA-1 hash of a file. The sha1_file() function uses the US Secure Hash Algorithm 1.

Syntax :

sha1_file(file,binary) ;

Parameter Values,

file: Required. It  takes a file as input.
binary : Optional. Specifies hex or binary output format.
            TRUE - Raw 20 character binary format
            FALSE - Default. 40 character hex number

Let's see below example to understand sha1_file() function.

Example :

<?php
$hex = sha1_file("https://www.aryatechno.com/all/img/logo.png");
echo "<br>It returns 40 character hex number :".$hex; // display SHA-1 hash of a file

$binary= sha1_file("https://www.aryatechno.com/all/img/logo.png",TRUE); // binary parameter is TRUE
echo "<br>It returns Raw 20 character binary format :".$binary; // display SHA-1 hash of a file

?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

57957