Re: UUID

From: Date: Tue, 12 Apr 2016 12:56:31 +0000
Subject: Re: UUID
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-92220@lists.php.net to get a copy of this message
On Tue, Apr 12, 2016 at 2:09 AM Sebastian Bergmann <sebastian@php.net> wrote: > In PHP 7.0 we introduced random_bytes() which wraps Linux's getrandom(2) > as well as Windows's CryptGenRandom() and uses /dev/urandom as a fallback. > > I think it would be great if we added a function that wraps > /proc/sys/kernel/random/uuid [2] and, if that exists, its equivalent on > Windows to make the generation of UUIDs easy. > > Thoughts? > I'd love to see UUID generation in core using a similar platform-based approach, as long as the implementation matches RFC 4122. Part of this will be determining which versions/variants should be supported: https://en.wikipedia.org/wiki/Universally_unique_identifier#RFC_4122_Variant Version 4 (random) UUIDs is an obvious choice, but should any others be supported initially? Perhaps the implementation could be a simple function named random_uuid() which either takes no parameters or a single parameter "$version" which defaults to 4? Regards, Colin

« previous php.internals (#92220) next »