Table of Contents

Syntax

string sha1_file(string $filename [, bool $raw_output = false] )

(PHP 4 >= 4.3.0, PHP 5)

$filename A file located on the local machine.
$raw_output If set to true, function returns a raw binary string containing the computed digest.
RETURNS Computes a checksum using the Secure Hash Algorithm and returns this as a string or a raw binary data.

What it Does

The sha1_file method computes a secure hash algorithm on a file which is commonly used as a checksum for a file. This function returns the hash as a string of hexadecimal characters or as a raw binary data (when $raw_output is set to true).

Example

// calulate the checksum for the current file
$sha1 = sha1_file(__FILE__);
echo 'My SHA1 Hash is: ' . $sha1;