PHP sha1_file() Function


The sha1_file() predifined function is used to calculates the SHA-1 hash of a file.

Syntax
sha1_file(file,raw)
Parameters
  • file - (Required) File to be calculated.
  • raw - (optional) A specify value hex or binary output format:
  • TRUE - Raw 20 character binary format
  • FALSE - Default. 40 character hex number.
Example
<?php
    $file = "file.txt";
    $sha1file = sha1_file($file);
    echo $sha1file;
?>

Output

da39a3ee5e6b4b0d3255bfef95601890afd80709

Prev Next