From: Operating system: NA PHP version: 5.3SVN-2011-01-10 (SVN) Package: Strings related Bug Type: Feature/Change Request Bug description:[feat] md5_file and sha1_file should accept an additional length
Description: ------------ Sometimes you want to have the md5() or sha1() from a file, but not the whole file. This is particularly handy when you want to sync directories and you don't want to md5 whole files but just the first 4096 or 8192 bytes to speed up the checking. This patch implements an additional parameter to md5_file() and sha1_file() where you can add the number of bytes that needs to be read/md5()'d from the source file. Test script: --------------- Returns the md5 from the first 8192 bytes from the iso-file: md5_file('dvdimage.iso', false, 8192); Returns the md5 from the complete file, even though length is way larger than the file: md5_file('dvdimage.iso', false, 81920000000); Expected result: ---------------- The md5_file() and sha1_file() functions actually accepting the additional parameter. Actual result: -------------- Currently, it does not accept a 3rd paramter. The patch adds the additional parameter (which defaults to -1, which means to read the complete file). Additionally added and fixed tests in md5_file.phpt and sha1_file.phpt -- Edit bug report at http://bugs.php.net/bug.php?id=53709&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53709&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53709&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53709&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53709&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53709&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53709&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53709&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53709&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53709&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53709&r=support Expected behavior: http://bugs.php.net/fix.php?id=53709&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53709&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53709&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53709&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53709&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53709&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53709&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53709&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53709&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53709&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53709&r=mysqlcfg