php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54667 $offset parameter for md5_file() and sha1_file()
Submitted: 2011-05-05 15:59 UTC Modified: 2018-09-14 16:58 UTC
From: delphists at apollo dot lv Assigned: cmb (profile)
Status: Closed Package: *Encryption and hash functions
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2011-05-05 15:59 UTC] 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?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-14 16:58 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-09-14 16:58 UTC] cmb@php.net
> 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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC