note 84653 added to function.hash-file
| From: | allaryin at gmail dot com | Date: | Wed, 23 Jul 2008 22:16:56 +0000 |
| Subject: | note 84653 added to function.hash-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142629@lists.php.net to get a copy of this message | ||
For those who are wondering, there appears to be no fundamental difference between
hash_file('md5')/hash_file('sha1') and md5_file()/sha1_file(). They produce
identical output and have comparable performance.
There is, however, a difference between hash_file('crc32') and something silly like
crc32(file_get_contents()).
crc32(file_get_contents())'s results are most similar to those of
hash_file('crc32b'), just with the octets reversed:
<?php
$fname = "something.png";
$hash = hash_file( 'crc32', $fname );
echo "crc32 = $hash\n";
$hash = hash_file( 'crc32b', $fname );
echo "crc32b = $hash\n";
$hash = sprintf("%x",crc32(file_get_contents($fname)));
echo "manual = $hash\n";
?>
crc32 = f41d7f4e
crc32b = 7dafbba4
manual = a4bbaf7d
----
Server IP: 64.71.164.2
Probable Submitter: 209.125.44.92
----
Manual Page -- http://www.php.net/manual/en/function.hash-file.php
Edit -- https://master.php.net/note/edit/84653
Del: integrated -- https://master.php.net/note/delete/84653/integrated
Del: useless -- https://master.php.net/note/delete/84653/useless
Del: bad code -- https://master.php.net/note/delete/84653/bad+code
Del: spam -- https://master.php.net/note/delete/84653/spam
Del: non-english -- https://master.php.net/note/delete/84653/non-english
Del: in docs -- https://master.php.net/note/delete/84653/in+docs
Del: other reasons-- https://master.php.net/note/delete/84653
Reject -- https://master.php.net/note/reject/84653
Search -- https://master.php.net/manage/user-notes.php