Re: New function proposal: spl_object_id
| From: | Etienne Kneuss | Date: | Tue, 20 Jan 2009 12:26:53 +0000 |
| Subject: | Re: New function proposal: spl_object_id | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42724@lists.php.net to get a copy of this message | ||
Hello,
On Tue, Jan 20, 2009 at 11:47 AM, Stan Vassilev | FM
<sv_forums@fmethod.com> wrote:
>
> Hi,
>
> I had a talk with Marcus, and he has agreed on this proposed solution:
>
> 1) SPL generates a pseudo-random session id/mask (for the current request,
> do not confuse with $_SESSION), which consists of 32 random
> bytes/characters.
> 2) The object is and the handler pointer are used to create a unique
> identifier for the object, by padding each pointer to 16 bytes and joining
> them together.
> 3) The resulting byte sequence is XOR-red with the session mask so the
> object id/handler are not retrievable in userland, and the resulting
> sequence/string is returned.
>
> This is better than spl_object_hash for two reasons:
>
> 1) no printf of numbers, no expensive md5 hashing, no hex conversion.
> 2) no possible collisions
>
> Drawbacks:
>
> 1) might generate some non-printable chars after xor (but this wouldn't
> matter for operation). The idea above can be tweaked to solve this.
>
> The "32-bit string" format is to preserve compatibility with
> spl_object_hash, so it can replace it, instead of introducing a new similar
> function.
>
> I've had no time to look further into this, but Marcus seems to like the
> basic idea, so feel welcome...
Could you please provide an example, with code, in which this function
would be necessary ? (i.e. where you can't use SplObjeccctStorage)
Thanks.
>
> Regards,
> Stan Vassilev
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal