Req #53709 [Com]: [feat] md5_file and sha1_file should accept an additional length

From: Date: Mon, 10 Jan 2011 21:18:27 +0000
Subject: Req #53709 [Com]: [feat] md5_file and sha1_file should accept an additional length
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157804@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53709&edit=1 ID: 53709 Comment by: jthijssen at noxlogic dot nl Reported by: jthijssen at noxlogic dot nl Summary: [feat] md5_file and sha1_file should accept an additional length Status: Open Type: Feature/Change Request Package: Strings related Operating System: NA PHP Version: 5.3SVN-2011-01-10 (SVN) Block user comment: N Private report: N New Comment: I've added the patch in a base64 format because of a bug in the php bugtracker (bug #53703). Previous Comments: ------------------------------------------------------------------------ [2011-01-10 22:11:44] jthijssen at noxlogic dot nl 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 this bug report at http://bugs.php.net/bug.php?id=53709&edit=1

« previous php.bugs (#157804) next »