Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

If you want to make a simple logic to get hash value for file, hash_file() gives you a straightforward solution.

Example using hash_file()

Code Block
<?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 below is the output for above

Code Block
5c6ffbdd40d9556b73a21e63c3e0e904