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?
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?
Alternatively and maybe more portable, libuuid (should be part of all
decent systems too) could be a first choice. BSD also provides
compliant APIs as part of their libc
(https://www.freebsd.org/cgi/man.cgi?query=uuid for freebsd f.e.). On
Windows
UuidCreate and UuidToString should do it but I did not check their
compliance yet.
For the reference here: by compliant, I mean compliant with
https://tools.ietf.org/html/rfc4122
Cheers,
Pierre
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?
Alternatively and maybe more portable, libuuid (should be part of all
decent systems too) could be a first choice.
Forgot to mention: https://pecl.php.net/package/uuid
BSD also provides
compliant APIs as part of their libc
(https://www.freebsd.org/cgi/man.cgi?query=uuid for freebsd f.e.). On
WindowsUuidCreate and UuidToString should do it but I did not check their
compliance yet.For the reference here: by compliant, I mean compliant with
https://tools.ietf.org/html/rfc4122Cheers,
Pierre
--
Pierre
@pierrejoye | http://www.libgd.org
Hi,
Alternatively and maybe more portable, libuuid (should be part of all
decent systems too) could be a first choice.Forgot to mention: https://pecl.php.net/package/uuid
BSD also provides
compliant APIs as part of their libc
(https://www.freebsd.org/cgi/man.cgi?query=uuid for freebsd f.e.).
I have worked on the addition of Linux libuuid + BSD support to Postgres
9.4 to the existing (deprecated) uuid-ossp a couple of years back. I
pretty sure we can reuse some of that investigation / code for php too.
Cheers
Matteo Beccati
Development & Consulting - http://www.beccati.com/
On Apr 12, 2016 1:09 PM, "Sebastian Bergmann" <sebastian@php.net
javascript:;> 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?
Alternatively and maybe more portable, libuuid (should be part of all
decent systems too) could be a first choice. BSD also provides
compliant APIs as part of their libc
(https://www.freebsd.org/cgi/man.cgi?query=uuid for freebsd f.e.). On
Windows
I have partially implemented bindings for libuuid into the core, I can
finish it if you will.
--Leszek
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
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?
I would prefer not to refer to random to avoid any confusion with the
recent added random function. As uuid is not crypto safe and is not aimed
to. Users will then hopefully not think about using instead of the random
api.
Also uuid alone may be a problem (bc?) It sounds like a logical choice.
Alternatively uuid_create ().
Cheers
Pierre
I would prefer not to refer to random to avoid any confusion with the
recent added random function. As uuid is not crypto safe and is not aimed
to. Users will then hopefully not think about using instead of the random
api.Also uuid alone may be a problem (bc?) It sounds like a logical choice.
Alternatively uuid_create ().
Ah yes, good point. I was thinking random_uuid() might be good for v4
UUIDs, and that a parameter might be needed, but I failed to make the
connection that not all UUID versions are random - my apologies for not
catching that before hitting send.
I like the idea of uuid() or uuid($version = 4)
Perhaps, no need to reinvent the wheel...
There is already 2 uuid extensions
- the one provided in the libuuid sources
- the pecl one : https://pecl.php.net/package/uuid
No need to create more confusion.
If something missing, just add it in the existing pecl ext.
If needed, open a RFC to merge the extension in php.
Remi.
Perhaps, no need to reinvent the wheel...
There is already 2 uuid extensions
- the one provided in the libuuid sources
- the pecl one : https://pecl.php.net/package/uuid
No need to create more confusion.
If something missing, just add it in the existing pecl ext.
If needed, open a RFC to merge the extension in php.
This is why I referred to this extension and lib. However they are
only based on libuuid. We still need to support windows and I would
prefer to use libc's uuid for BSD. I think pecl's uuid could be good
start to make it more portable across system.
The API is already clear (generation and comparison, not sure we need
much more). I am not sure either about the various platforms and what
they support in term of UUID versions. We have to clarify this point
before anything can be merged.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org