hash_file_basic.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Hash: hash_file() function : basic functionality
  3. --CREDITS--
  4. Felix De Vliegher <felix.devliegher@gmail.com>
  5. --FILE--
  6. <?php
  7. echo "*** Testing hash_file() : basic functionality ***\n";
  8. // Set up file
  9. $filename = 'hash_file_basic_example.txt';
  10. file_put_contents( $filename, 'The quick brown fox jumped over the lazy dog.' );
  11. var_dump( hash_file( 'md5', $filename ) );
  12. var_dump( hash_file( 'sha1', $filename ) );
  13. var_dump( hash_file( 'sha256', $filename ) );
  14. var_dump( hash_file( 'sha512', $filename ) );
  15. var_dump( base64_encode( hash_file( 'md5', $filename, true ) ) );
  16. ?>
  17. --CLEAN--
  18. <?php
  19. $filename = 'hash_file_basic_example.txt';
  20. unlink( $filename );
  21. ?>
  22. --EXPECT--
  23. *** Testing hash_file() : basic functionality ***
  24. string(32) "5c6ffbdd40d9556b73a21e63c3e0e904"
  25. string(40) "c0854fb9fb03c41cce3802cb0d220529e6eef94e"
  26. string(64) "68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483"
  27. string(128) "0a8c150176c2ba391d7f1670ef4955cd99d3c3ec8cf06198cec30d436f2ac0c9b64229b5a54bdbd5563160503ce992a74be528761da9d0c48b7c74627302eb25"
  28. string(24) "XG/73UDZVWtzoh5jw+DpBA=="