Req #54667 [Opn->Csd]: $offset parameter for md5_file() and sha1_file()

From: Date: Fri, 14 Sep 2018 16:58:57 +0000
Subject: Req #54667 [Opn->Csd]: $offset parameter for md5_file() and sha1_file()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217057@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54667&edit=1 ID: 54667 Updated by: cmb@php.net Reported by: delphists at apollo dot lv Summary: $offset parameter for md5_file() and sha1_file() -Status: Open +Status: Closed Type: Feature/Change Request Package: *Encryption and hash functions PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > Any chance to see it implemented some day? Since there are hash_init()[1] and friends, I don't think so. If you want to have this feature nonetheless, please feel free to start the RFC process[2]. [1] <http://php.net/manual/en/function.hash-init.php> [2] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2011-05-05 15:59:44] delphists at apollo dot lv Description: ------------ There are some functions that calculate hash from a file, e.g., md5_file() and sha1_file(), but they work only for whole files. There's also a function (or a language construct?) __halt_compiler(), which is useful for making "installers", as it allows to mix PHP code and binary data (e.g., compressed archive) in a single file. To make sure that whole "installer" is correctly downloaded, it would be worth to validate checksum of binary data by comparing it with value of checksum that is stored in PHP code part (i.e., before __halt_compiler()). Currently, checksum of binary data may be calculated by fully loading binary data and calling md5() or sha1() on a string. It is not a problem for smaller installers, but if installer is larger (e.g., because of having lots of images in it), it might require too much memory to be loaded into a string. In this case, it would be handy to use md5_file() or sha1_file() with 3rd parameter - $offset, something like md5_file($filename, false, __COMPILER_HALT_OFFSET__). Any chance to see it implemented some day? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54667&edit=1

« previous php.bugs (#217057) next »