Generate a hash value using the contents of a given file with hash_file() in PHP

Description

The following code shows how to generate a hash value using the contents of a given file with hash_file().

Example


//from  w  w  w.j av a2  s  .com
<?php
/* Create a file to calculate hash of */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');

echo hash_file('md5', 'example.txt');
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions