Req #80221 [Opn->Sus]: Object-oriented interface for HashContext
| From: | cmb@php.net | Date: | Mon, 12 Oct 2020 11:01:35 +0000 |
| Subject: | Req #80221 [Opn->Sus]: Object-oriented interface for HashContext | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229556@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80221&edit=1
ID: 80221
Updated by: cmb@php.net
Reported by: divinity76 at gmail dot com
Summary: Object-oriented interface for HashContext
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: hash related
PHP Version: Next Minor Version
Block user comment: N
Private report: N
New Comment:
That makes sense, but the details need to be discussed (and the
feature may require an RFC[1]), and this bug tracker isn't really
suitable for that kind of discussion. Therefore please forward
that request to the internals mailing list[2]. For the time
being, I'm suspending this ticket.
[1] <https://wiki.php.net/rfc/howto>
[2] <https://www.php.net/mailing-lists.php#internals>
Previous Comments:
------------------------------------------------------------------------
[2020-10-12 10:02:54] divinity76 at gmail dot com
Description:
------------
the current HashContext only has a procedural interface,
some people would prefer having an Object-oriented interface instead. (the same way mysqli_query()
& co has both a procedural and object-oriented api)
for example, the current way to hash $str1 and $str2 is:
$hc = hash_init("SHA1");
hash_update($hc, $str1);
hash_update($hc, $str2);
$result = hash_final($hc);
(i've omitted error-checking for brevity)
but if we had an OO interface, it could also be written as:
$result = (new HashContext("SHA1"))->update($str1)->update($str2)->final();
some people would prefer that. something like this: https://3v4l.org/lXd3u
Test script:
---------------
<?php
$str1 = "foo";
$str2 = "bar";
$result = (new HashContext("SHA1"))->update($str1)->update($str2)->final();
echo $result;
Expected result:
----------------
8843d7f92416211de9ebb963ff4ce28125932878
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80221&edit=1